diff options
Diffstat (limited to 'binfilter/bf_svx/source/editeng')
31 files changed, 18322 insertions, 0 deletions
diff --git a/binfilter/bf_svx/source/editeng/editattr.hxx b/binfilter/bf_svx/source/editeng/editattr.hxx new file mode 100644 index 000000000000..f9f99f96488b --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editattr.hxx @@ -0,0 +1,420 @@ +/* -*- 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 _EDITATTR_HXX +#define _EDITATTR_HXX + +#include <eeitemid.hxx> +namespace binfilter { + +class SvxFont; +class SvxFontItem; +class SvxWeightItem; +class SvxPostureItem; +class SvxShadowedItem; +class SvxEscapementItem; +class SvxContourItem; +class SvxCrossedOutItem; +class SvxUnderlineItem; +class SvxFontHeightItem; +class SvxCharScaleWidthItem; +class SvxColorItem; +class SvxAutoKernItem; +class SvxKerningItem; +class SvxCharSetColorItem; +class SvxWordLineModeItem; +class SvxFieldItem; +class SvxLanguageItem; +class SvxEmphasisMarkItem; +class SvxCharReliefItem; +}//end of namespace binfilter +#include <bf_svtools/poolitem.hxx> +class SfxVoidItem; +namespace binfilter { + + +#define CH_FEATURE_OLD (BYTE) 0xFF +#define CH_FEATURE (sal_Unicode) 0x01 + +// DEF_METRIC: Bei meinem Pool sollte immer die DefMetric bei +// GetMetric( nWhich ) ankommen! +// => Zum ermitteln der DefMetrik einfach ein GetMetric( 0 ) +#define DEF_METRIC 0 + +// ------------------------------------------------------------------------- +// class EditAttrib +// ------------------------------------------------------------------------- +class EditAttrib +{ +private: + EditAttrib() {;} + EditAttrib( const EditAttrib & ) {;} + +protected: + const SfxPoolItem* pItem; + + EditAttrib( const SfxPoolItem& rAttr ); + virtual ~EditAttrib(); + +public: + // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! + void RemoveFromPool( SfxItemPool& rPool ); + + USHORT Which() const { return pItem->Which(); } + const SfxPoolItem* GetItem() const { return pItem; } +}; + +// ------------------------------------------------------------------------- +// class EditCharAttrib +// ------------------------------------------------------------------------- +// bFeature: Attribut darf nicht expandieren/schrumfen, Laenge immer 1 +// bEdge: Attribut expandiert nicht, wenn genau an der Kante expandiert werden soll +class EditCharAttrib : public EditAttrib +{ +protected: + + USHORT nStart; + USHORT nEnd; + BOOL bFeature :1; + BOOL bEdge :1; + +public: + EditCharAttrib( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + + USHORT& GetStart() { return nStart; } + USHORT& GetEnd() { return nEnd; } + + USHORT GetStart() const { return nStart; } + USHORT GetEnd() const { return nEnd; } + + inline USHORT GetLen() const; + + inline void MoveForward( USHORT nDiff ); + inline void MoveBackward( USHORT nDiff ); + + inline void Expand( USHORT nDiff ); + inline void Collaps( USHORT nDiff ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); + + BOOL IsIn( USHORT nIndex ) + { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); } + BOOL IsInside( USHORT nIndex ) + { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); } + BOOL IsEmpty() + { return nStart == nEnd; } + + BOOL IsFeature() const { return bFeature; } + void SetFeature( BOOL b) { bFeature = b; } + + BOOL IsEdge() const { return bEdge; } + void SetEdge( BOOL b ) { bEdge = b; } +}; + +inline USHORT EditCharAttrib::GetLen() const +{ + DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" ); + return nEnd-nStart; +} + +inline void EditCharAttrib::MoveForward( USHORT nDiff ) +{ + DBG_ASSERT( ((long)nEnd + nDiff) <= 0xFFFF, "EditCharAttrib: MoveForward?!" ); + nStart += nDiff; + nEnd += nDiff; +} + +inline void EditCharAttrib::MoveBackward( USHORT nDiff ) +{ + DBG_ASSERT( ((long)nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" ); + nStart -= nDiff; + nEnd -= nDiff; +} + +inline void EditCharAttrib::Expand( USHORT nDiff ) +{ + DBG_ASSERT( ( ((long)nEnd + nDiff) <= (long)0xFFFF ), "EditCharAttrib: Expand?!" ); + DBG_ASSERT( !bFeature, "Bitte keine Features expandieren!" ); + nEnd += nDiff; +} + +inline void EditCharAttrib::Collaps( USHORT nDiff ) +{ + DBG_ASSERT( (long)nEnd - nDiff >= (long)nStart, "EditCharAttrib: Collaps?!" ); + DBG_ASSERT( !bFeature, "Bitte keine Features schrumpfen!" ); + nEnd -= nDiff; +} + +// ------------------------------------------------------------------------- +// class EditCharAttribFont +// ------------------------------------------------------------------------- +class EditCharAttribFont: public EditCharAttrib +{ +public: + EditCharAttribFont( const SvxFontItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribWeight +// ------------------------------------------------------------------------- +class EditCharAttribWeight : public EditCharAttrib +{ +public: + EditCharAttribWeight( const SvxWeightItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; +// ------------------------------------------------------------------------- +// class EditCharAttribItalic +// ------------------------------------------------------------------------- +class EditCharAttribItalic : public EditCharAttrib +{ +public: + EditCharAttribItalic( const SvxPostureItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribShadow +// ------------------------------------------------------------------------- +class EditCharAttribShadow : public EditCharAttrib +{ +public: + EditCharAttribShadow( const SvxShadowedItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribEscapement +// ------------------------------------------------------------------------- +class EditCharAttribEscapement : public EditCharAttrib +{ +public: + EditCharAttribEscapement( const SvxEscapementItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribOutline +// ------------------------------------------------------------------------- +class EditCharAttribOutline : public EditCharAttrib +{ +public: + EditCharAttribOutline( const SvxContourItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribStrikeout +// ------------------------------------------------------------------------- +class EditCharAttribStrikeout : public EditCharAttrib +{ +public: + EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribUnderline +// ------------------------------------------------------------------------- +class EditCharAttribUnderline : public EditCharAttrib +{ +public: + EditCharAttribUnderline( const SvxUnderlineItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribEmphasisMark +// ------------------------------------------------------------------------- +class EditCharAttribEmphasisMark : public EditCharAttrib +{ +public: + EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribRelief +// ------------------------------------------------------------------------- +class EditCharAttribRelief : public EditCharAttrib +{ +public: + EditCharAttribRelief( const SvxCharReliefItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribFontHeight +// ------------------------------------------------------------------------- +class EditCharAttribFontHeight : public EditCharAttrib +{ +public: + EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribFontWidth +// ------------------------------------------------------------------------- +class EditCharAttribFontWidth : public EditCharAttrib +{ +public: + EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribColor +// ------------------------------------------------------------------------- +class EditCharAttribColor : public EditCharAttrib +{ +public: + EditCharAttribColor( const SvxColorItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribLanguage +// ------------------------------------------------------------------------- +class EditCharAttribLanguage : public EditCharAttrib +{ +public: + EditCharAttribLanguage( const SvxLanguageItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribTab +// ------------------------------------------------------------------------- +class EditCharAttribTab : public EditCharAttrib +{ +public: + EditCharAttribTab( const SfxVoidItem& rAttr, USHORT nPos ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribLineBreak +// ------------------------------------------------------------------------- +class EditCharAttribLineBreak : public EditCharAttrib +{ +public: + EditCharAttribLineBreak( const SfxVoidItem& rAttr, USHORT nPos ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribField +// ------------------------------------------------------------------------- +class EditCharAttribField: public EditCharAttrib +{ + XubString aFieldValue; + Color* pTxtColor; + Color* pFldColor; + + EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) const; + +public: + EditCharAttribField( const SvxFieldItem& rAttr, USHORT nPos ); + EditCharAttribField( const EditCharAttribField& rAttr ); + ~EditCharAttribField(); + + BOOL operator == ( const EditCharAttribField& rAttr ) const; + BOOL operator != ( const EditCharAttribField& rAttr ) const + { return !(operator == ( rAttr ) ); } + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); + Color*& GetTxtColor() { return pTxtColor; } + Color*& GetFldColor() { return pFldColor; } + + const XubString& GetFieldValue() const { return aFieldValue; } + XubString& GetFieldValue() { return aFieldValue; } + + void Reset() + { + aFieldValue.Erase(); + delete pTxtColor; pTxtColor = 0; + delete pFldColor; pFldColor = 0; + } +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribPairKerning +// ------------------------------------------------------------------------- +class EditCharAttribPairKerning : public EditCharAttrib +{ +public: + EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribKerning +// ------------------------------------------------------------------------- +class EditCharAttribKerning : public EditCharAttrib +{ +public: + EditCharAttribKerning( const SvxKerningItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + +// ------------------------------------------------------------------------- +// class EditCharAttribWordLineMode +// ------------------------------------------------------------------------- +class EditCharAttribWordLineMode: public EditCharAttrib +{ +public: + EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, USHORT nStart, USHORT nEnd ); + + virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ); +}; + + +}//end of namespace binfilter +#endif // _EDITATTR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/editdoc.hxx b/binfilter/bf_svx/source/editeng/editdoc.hxx new file mode 100644 index 000000000000..c9240a335141 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editdoc.hxx @@ -0,0 +1,718 @@ +/* -*- 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 _EDITDOC_HXX +#define _EDITDOC_HXX + +#include <editattr.hxx> +#include <svxfont.hxx> + +#include <bf_svtools/itemset.hxx> + +#include <bf_svtools/style.hxx> + +#include <bf_svtools/itempool.hxx> + +#include <tools/table.hxx> +namespace binfilter { + +class ImpEditEngine; +class SvxTabStop; + +DBG_NAMEEX( EE_TextPortion )//STRIP008 + +#define CHARPOSGROW 16 +#define DEFTAB 720 + +void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, BOOL bSearchInParent = TRUE, short nScriptType = 0 ); +USHORT GetScriptItemId( USHORT nItemId, short nScriptType ); +BOOL IsScriptItemValid( USHORT nItemId, short nScriptType ); + +EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, USHORT nS, USHORT nE ); + +class ContentNode; +class EditDoc; + +struct EPaM +{ + USHORT nPara; + USHORT nIndex; + + EPaM() { nPara = 0; nIndex = 0; } + EPaM( USHORT nP, USHORT nI ) { nPara = nP; nIndex = nI; } + EPaM( const EPaM& r) { nPara = r.nPara; nIndex = r.nIndex; } + EPaM& operator = ( const EPaM& r ) { nPara = r.nPara; nIndex = r.nIndex; return *this; } + inline BOOL operator == ( const EPaM& r ) const; + inline BOOL operator < ( const EPaM& r ) const; +}; + +inline BOOL EPaM::operator < ( const EPaM& r ) const +{ + return ( ( nPara < r.nPara ) || + ( ( nPara == r.nPara ) && nIndex < r.nIndex ) ) ? TRUE : FALSE; +} + +inline BOOL EPaM::operator == ( const EPaM& r ) const +{ + return ( ( nPara == r.nPara ) && ( nIndex == r.nIndex ) ) ? TRUE : FALSE; +} + +struct ScriptTypePosInfo +{ + short nScriptType; + USHORT nStartPos; + USHORT nEndPos; + + ScriptTypePosInfo( short _Type, USHORT _Start, USHORT _End ) + { + nScriptType = _Type; + nStartPos = _Start; + nEndPos = _End; + } +}; + +SV_DECL_VARARR( ScriptTypePosInfos, ScriptTypePosInfo, 0, 4 )//STRIP008 ; + +struct WritingDirectionInfo +{ + BYTE nType; + USHORT nStartPos; + USHORT nEndPos; + + WritingDirectionInfo( BYTE _Type, USHORT _Start, USHORT _End ) + { + nType = _Type; + nStartPos = _Start; + nEndPos = _End; + } +}; + +SV_DECL_VARARR( WritingDirectionInfos, WritingDirectionInfo, 0, 4 )//STRIP008 ; + +typedef EditCharAttrib* EditCharAttribPtr; +SV_DECL_PTRARR( CharAttribArray, EditCharAttribPtr, 0, 4 )//STRIP008 ; + + + +// ---------------------------------------------------------------------- +// class SvxFontTable +// ---------------------------------------------------------------------- + +// ---------------------------------------------------------------------- +// class SvxColorList +// ---------------------------------------------------------------------- + +// ---------------------------------------------------------------------- +// class ItemList +// ---------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +// class ContentAttribs +// ------------------------------------------------------------------------- +class ContentAttribs +{ +private: + SfxStyleSheet* pStyle; + SfxItemSet aAttribSet; + +public: + ContentAttribs( SfxItemPool& rItemPool ); + ContentAttribs( const ContentAttribs& ); + ~ContentAttribs(); // erst bei umfangreicheren Tabs + + SvxTabStop FindTabStop( long nCurPos, USHORT nDefTab ); + SfxItemSet& GetItems() { return aAttribSet; } + SfxStyleSheet* GetStyleSheet() const { return pStyle; } + void SetStyleSheet( SfxStyleSheet* pS ); + + const SfxPoolItem& GetItem( USHORT nWhich ); + BOOL HasItem( USHORT nWhich ); +}; + +// ------------------------------------------------------------------------- +// class CharAttribList +// ------------------------------------------------------------------------- +class CharAttribList +{ +private: + CharAttribArray aAttribs; + SvxFont aDefFont; // schneller, als jedesmal vom Pool! + BOOL bHasEmptyAttribs; + + CharAttribList( const CharAttribList& ) {;} + +public: + CharAttribList(); + ~CharAttribList(); + + void RemoveItemsFromPool( SfxItemPool* pItemPool ); + + EditCharAttrib* FindAttrib( USHORT nWhich, USHORT nPos ); + EditCharAttrib* FindNextAttrib( USHORT nWhich, USHORT nFromPos ) const; + EditCharAttrib* FindEmptyAttrib( USHORT nWhich, USHORT nPos ); + EditCharAttrib* FindFeature( USHORT nPos ) const; + + + void ResortAttribs(); + void OptimizeRanges( SfxItemPool& rItemPool ); + + USHORT Count() { return aAttribs.Count(); } + void Clear() { aAttribs.Remove( 0, aAttribs.Count()); } + void InsertAttrib( EditCharAttrib* pAttrib ); + + SvxFont& GetDefFont() { return aDefFont; } + + BOOL HasEmptyAttribs() const { return bHasEmptyAttribs; } + BOOL& HasEmptyAttribs() { return bHasEmptyAttribs; } + BOOL HasBoundingAttrib( USHORT nBound ); + + CharAttribArray& GetAttribs() { return aAttribs; } + const CharAttribArray& GetAttribs() const { return aAttribs; } + + // Debug: +}; + +// ------------------------------------------------------------------------- +// class ContentNode +// ------------------------------------------------------------------------- +class ContentNode : public XubString +{ +private: + ContentAttribs aContentAttribs; + CharAttribList aCharAttribList; + +public: + ContentNode( SfxItemPool& rItemPool ); + ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs ); + ~ContentNode(); + + ContentAttribs& GetContentAttribs() { return aContentAttribs; } + CharAttribList& GetCharAttribs() { return aCharAttribList; } + + void ExpandAttribs( USHORT nIndex, USHORT nNewChars, SfxItemPool& rItemPool ); + void CollapsAttribs( USHORT nIndex, USHORT nDelChars, SfxItemPool& rItemPool ); + void AppendAttribs( ContentNode* pNextNode ); + void CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, BOOL bKeepEndingAttribs ); + + void SetStyleSheet( SfxStyleSheet* pS, BOOL bRecalcFont = TRUE ); + SfxStyleSheet* GetStyleSheet() { return aContentAttribs.GetStyleSheet(); } + + void CreateDefFont(); + + BOOL IsFeature( USHORT nPos ) const { return ( GetChar( nPos ) == CH_FEATURE ); } +}; + +typedef ContentNode* ContentNodePtr; +SV_DECL_PTRARR( ContentList, ContentNodePtr, 0, 4 )//STRIP008 ; + +// ------------------------------------------------------------------------- +// class EditPaM +// ------------------------------------------------------------------------- +class EditPaM +{ +private: + ContentNode* pNode; + USHORT nIndex; + +public: + EditPaM() { pNode = NULL; nIndex = 0; } + EditPaM( ContentNode* p, USHORT n ) { pNode = p; nIndex = n; } + + ContentNode* GetNode() const { return pNode; } + void SetNode( ContentNode* p) { pNode = p; } + + USHORT GetIndex() const { return nIndex; } + USHORT& GetIndex() { return nIndex; } + void SetIndex( USHORT n ) { nIndex = n; } + + BOOL IsParaStart() const { return nIndex == 0; } + BOOL IsParaEnd() const { return nIndex == pNode->Len(); } + + EditPaM& operator = ( const EditPaM& rPaM ); + friend BOOL operator == ( const EditPaM& r1, const EditPaM& r2 ); + friend BOOL operator != ( const EditPaM& r1, const EditPaM& r2 ); +}; + +#define PORTIONKIND_TEXT 0 +#define PORTIONKIND_TAB 1 +#define PORTIONKIND_LINEBREAK 2 +#define PORTIONKIND_FIELD 3 +#define PORTIONKIND_HYPHENATOR 4 +// #define PORTIONKIND_EXTRASPACE 5 + +#define DELMODE_SIMPLE 0 +#define DELMODE_RESTOFWORD 1 +#define DELMODE_RESTOFCONTENT 2 + +#define CHAR_NORMAL 0x00 +#define CHAR_KANA 0x01 +#define CHAR_PUNCTUATIONLEFT 0x02 +#define CHAR_PUNCTUATIONRIGHT 0x04 + +// ------------------------------------------------------------------------- +// struct ExtraPortionInfos +// ------------------------------------------------------------------------- +struct ExtraPortionInfo +{ + long nOrgWidth; + long nWidthFullCompression; + + long nPortionOffsetX; + + USHORT nMaxCompression100thPercent; + + BYTE nAsianCompressionTypes; + BOOL bFirstCharIsRightPunktuation; + BOOL bCompressed; + + long* pOrgDXArray; + + ~ExtraPortionInfo(); + +}; + + +// ------------------------------------------------------------------------- +// class TextPortion +// ------------------------------------------------------------------------- +class TextPortion +{ +private: + ExtraPortionInfo* pExtraInfos; + USHORT nLen; + Size aOutSz; + BYTE nKind; + BYTE nRightToLeft; + sal_Unicode nExtraValue; + + + TextPortion() { DBG_CTOR( EE_TextPortion, 0 ); + pExtraInfos = NULL; nLen = 0; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = FALSE;} + +public: + TextPortion( USHORT nL ) : aOutSz( -1, -1 ) + { DBG_CTOR( EE_TextPortion, 0 ); + pExtraInfos = NULL; nLen = nL; nKind = PORTIONKIND_TEXT; nExtraValue = 0; nRightToLeft = FALSE;} + TextPortion( const TextPortion& r ) : aOutSz( r.aOutSz ) + { DBG_CTOR( EE_TextPortion, 0 ); + pExtraInfos = NULL; nLen = r.nLen; nKind = r.nKind; nExtraValue = r.nExtraValue; nRightToLeft = r.nRightToLeft; } + + ~TextPortion() { DBG_DTOR( EE_TextPortion, 0 ); delete pExtraInfos; } + + USHORT GetLen() const { return nLen; } + USHORT& GetLen() { return nLen; } + void SetLen( USHORT nL ) { nLen = nL; } + + Size& GetSize() { return aOutSz; } + Size GetSize() const { return aOutSz; } + + BYTE& GetKind() { return nKind; } + BYTE GetKind() const { return nKind; } + + void SetRightToLeft( BYTE b ) { nRightToLeft = b; } + BYTE GetRightToLeft() const { return nRightToLeft; } + BOOL IsRightToLeft() const { return (nRightToLeft&1); } + + sal_Unicode GetExtraValue() const { return nExtraValue; } + void SetExtraValue( sal_Unicode n ) { nExtraValue = n; } + + BOOL HasValidSize() const { return aOutSz.Width() != (-1); } + + ExtraPortionInfo* GetExtraInfos() const { return pExtraInfos; } + void SetExtraInfos( ExtraPortionInfo* p ) { delete pExtraInfos; pExtraInfos = p; } +}; + +// ------------------------------------------------------------------------- +// class TextPortionList +// ------------------------------------------------------------------------- +typedef TextPortion* TextPortionPtr; +SV_DECL_PTRARR( TextPortionArray, TextPortionPtr, 0, 8 )//STRIP008 ; + +class TextPortionList : public TextPortionArray +{ +public: + TextPortionList(); + ~TextPortionList(); + + void Reset(); + USHORT FindPortion( USHORT nCharPos, USHORT& rPortionStart, BOOL bPreferStartingPortion = FALSE ); + void DeleteFromPortion( USHORT nDelFrom ); +}; + +class ParaPortion; + +SV_DECL_VARARR( CharPosArray, sal_Int32, 0, CHARPOSGROW )//STRIP008 ; + +// ------------------------------------------------------------------------ +// class EditLine +// ------------------------------------------------------------------------- +class EditLine +{ +private: + CharPosArray aPositions; + long nTxtWidth; + USHORT nStartPosX; + USHORT nStart; // koennte durch nStartPortion ersetzt werden + USHORT nEnd; // koennte durch nEndPortion ersetzt werden + USHORT nStartPortion; + USHORT nEndPortion; + USHORT nHeight; // Gesamthoehe der Zeile + USHORT nTxtHeight; // Reine Texthoehe + USHORT nCrsrHeight; // Bei Konturfluss hohe Zeilen => Cursor zu gro? + USHORT nMaxAscent; + BOOL bHangingPunctuation; + BOOL bInvalid; // fuer geschickte Formatierung + +public: + EditLine(); + EditLine( const EditLine& ); + ~EditLine(); + + BOOL IsIn( USHORT nIndex ) const + { return ( (nIndex >= nStart ) && ( nIndex < nEnd ) ); } + + BOOL IsIn( USHORT nIndex, BOOL bInclEnd ) const + { return ( ( nIndex >= nStart ) && ( bInclEnd ? ( nIndex <= nEnd ) : ( nIndex < nEnd ) ) ); } + + void SetStart( USHORT n ) { nStart = n; } + USHORT GetStart() const { return nStart; } + USHORT& GetStart() { return nStart; } + + void SetEnd( USHORT n ) { nEnd = n; } + USHORT GetEnd() const { return nEnd; } + USHORT& GetEnd() { return nEnd; } + + void SetStartPortion( USHORT n ) { nStartPortion = n; } + USHORT GetStartPortion() const { return nStartPortion; } + USHORT& GetStartPortion() { return nStartPortion; } + + void SetEndPortion( USHORT n ) { nEndPortion = n; } + USHORT GetEndPortion() const { return nEndPortion; } + USHORT& GetEndPortion() { return nEndPortion; } + + void SetHeight( USHORT nH, USHORT nTxtH = 0, USHORT nCrsrH = 0 ) + { nHeight = nH; + nTxtHeight = ( nTxtH ? nTxtH : nH ); + nCrsrHeight = ( nCrsrH ? nCrsrH : nTxtHeight ); + } + USHORT GetHeight() const { return nHeight; } + USHORT GetTxtHeight() const { return nTxtHeight; } + USHORT GetCrsrHeight() const { return nCrsrHeight; } + + void SetTextWidth( long n ) { nTxtWidth = n; } + long GetTextWidth() const { return nTxtWidth; } + + void SetMaxAscent( USHORT n ) { nMaxAscent = n; } + USHORT GetMaxAscent() const { return nMaxAscent; } + + void SetHangingPunctuation( BOOL b ) { bHangingPunctuation = b; } + BOOL IsHangingPunctuation() const { return bHangingPunctuation; } + + USHORT GetLen() const { return nEnd - nStart; } + + USHORT GetStartPosX() const { return nStartPosX; } + void SetStartPosX( USHORT nStart ) { nStartPosX = nStart; } + + Size CalcTextSize( ParaPortion& rParaPortion ); + + BOOL IsInvalid() const { return bInvalid; } + BOOL IsValid() const { return !bInvalid; } + void SetInvalid() { bInvalid = TRUE; } + void SetValid() { bInvalid = FALSE; } + + BOOL IsEmpty() const { return (nEnd > nStart) ? FALSE : TRUE; } + + CharPosArray& GetCharPosArray() { return aPositions; } + + + EditLine& operator = ( const EditLine& rLine ); + friend BOOL operator == ( const EditLine& r1, const EditLine& r2 ); + friend BOOL operator != ( const EditLine& r1, const EditLine& r2 ); +}; + + +// ------------------------------------------------------------------------- +// class LineList +// ------------------------------------------------------------------------- +typedef EditLine* EditLinePtr; +SV_DECL_PTRARR( LineArray, EditLinePtr, 0, 4 )//STRIP008 ; + +class EditLineList : public LineArray +{ +public: + EditLineList(); + ~EditLineList(); + + void Reset(); + void DeleteFromLine( USHORT nDelFrom ); +}; + +// ------------------------------------------------------------------------- +// class ParaPortion +// ------------------------------------------------------------------------- +class ParaPortion +{ + friend class ImpEditEngine; // zum Einstellen der Hoehe +private: + EditLineList aLineList; + TextPortionList aTextPortionList; + ContentNode* pNode; + long nHeight; + + ScriptTypePosInfos aScriptInfos; + WritingDirectionInfos aWritingDirectionInfos; + + USHORT nInvalidPosStart; + USHORT nFirstLineOffset; // Fuer Writer-LineSpacing-Interpretation + USHORT nBulletX; + short nInvalidDiff; + + BOOL bInvalid : 1; + BOOL bSimple : 1; // nur lineares Tippen + BOOL bVisible : 1; // MT 05/00: Gehoert an den Node!!! + BOOL bForceRepaint : 1; + + ParaPortion( const ParaPortion& ); + +public: + ParaPortion( ContentNode* pNode ); + ~ParaPortion(); + + USHORT GetLineNumber( USHORT nIndex ); + + EditLineList& GetLines() { return aLineList; } + + BOOL IsInvalid() const { return bInvalid; } + BOOL IsSimpleInvalid() const { return bSimple; } + void SetValid() { bInvalid = FALSE; bSimple = TRUE;} + + BOOL MustRepaint() const { return bForceRepaint; } + void SetMustRepaint( BOOL bRP ) { bForceRepaint = bRP; } + + USHORT GetBulletX() const { return nBulletX; } + void SetBulletX( USHORT n ) { nBulletX = n; } + + void MarkInvalid( USHORT nStart, short nDiff); + void MarkSelectionInvalid( USHORT nStart, USHORT nEnd ); + + BOOL IsVisible() { return bVisible; } + + long GetHeight() const { return ( bVisible ? nHeight : 0 ); } + USHORT GetFirstLineOffset() const { return ( bVisible ? nFirstLineOffset : 0 ); } + void ResetHeight() { nHeight = 0; nFirstLineOffset = 0; } + + ContentNode* GetNode() const { return pNode; } + TextPortionList& GetTextPortions() { return aTextPortionList; } + + USHORT GetInvalidPosStart() const { return nInvalidPosStart; } + short GetInvalidDiff() const { return nInvalidDiff; } + + void CorrectValuesBehindLastFormattedLine( USHORT nLastFormattedLine ); + +}; + +typedef ParaPortion* ParaPortionPtr; +SV_DECL_PTRARR( DummyParaPortionList, ParaPortionPtr, 0, 4 )//STRIP008 ; + +// ------------------------------------------------------------------------- +// class ParaPortionList +// ------------------------------------------------------------------------- +class ParaPortionList : public DummyParaPortionList +{ +public: + ParaPortionList(); + ~ParaPortionList(); + + void Reset(); + long GetYOffset( ParaPortion* pPPortion ); + USHORT FindParagraph( long nYOffset ); + + inline ParaPortion* SaveGetObject( USHORT nPos ) const + { return ( nPos < Count() ) ? GetObject( nPos ) : 0; } + + // temporaer: +}; + +// ------------------------------------------------------------------------- +// class EditSelection +// ------------------------------------------------------------------------- +class EditSelection +{ +private: + EditPaM aStartPaM; + EditPaM aEndPaM; + +public: + EditSelection(); // kein CCTOR und DTOR, geht autom. richtig! + EditSelection( const EditPaM& rStartAndAnd ); + EditSelection( const EditPaM& rStart, const EditPaM& rEnd ); + + EditPaM& Min() { return aStartPaM; } + EditPaM& Max() { return aEndPaM; } + + const EditPaM& Min() const { return aStartPaM; } + const EditPaM& Max() const { return aEndPaM; } + + BOOL HasRange() const { return aStartPaM != aEndPaM; } + + BOOL Adjust( const ContentList& rNodes ); + + EditSelection& operator = ( const EditPaM& r ); + BOOL operator == ( const EditSelection& r ) const + { return ( ( aStartPaM == r.aStartPaM ) && ( aEndPaM == r.aEndPaM ) ) + ? TRUE : FALSE; } + BOOL operator != ( const EditSelection& r ) const { return !( r == *this ); } +}; + +// ------------------------------------------------------------------------- +// class DeletedNodeInfo +// ------------------------------------------------------------------------- +class DeletedNodeInfo +{ +private: + ULONG nInvalidAdressPtr; + USHORT nInvalidParagraph; + +public: + DeletedNodeInfo( ULONG nInvAdr, USHORT nPos ) + { nInvalidAdressPtr = nInvAdr; + nInvalidParagraph = nPos; } + + ULONG GetInvalidAdress() { return nInvalidAdressPtr; } + USHORT GetPosition() { return nInvalidParagraph; } +}; + +typedef DeletedNodeInfo* DeletedNodeInfoPtr; +SV_DECL_PTRARR( DeletedNodesList, DeletedNodeInfoPtr, 0, 4 )//STRIP008 ; + +// ------------------------------------------------------------------------- +// class EditDoc +// ------------------------------------------------------------------------- +class EditDoc : public ContentList +{ +private: + SfxItemPool* pItemPool; + Link aModifyHdl; + + SvxFont aDefFont; //schneller, als jedesmal vom Pool! + USHORT nDefTab; + BOOL bIsVertical; + + BOOL bOwnerOfPool; + BOOL bModified; + +protected: + void ImplDestroyContents(); + +public: + EditDoc( SfxItemPool* pItemPool ); + ~EditDoc(); + + BOOL IsModified() const { return bModified; } + void SetModified( BOOL b ); + + void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; } + Link GetModifyHdl() const { return aModifyHdl; } + + void CreateDefFont( BOOL bUseStyles ); + const SvxFont& GetDefFont() { return aDefFont; } + + void SetDefTab( USHORT nTab ) { nDefTab = nTab ? nTab : DEFTAB; } + USHORT GetDefTab() const { return nDefTab; } + + void SetVertical( BOOL bVertical ) { bIsVertical = bVertical; } + BOOL IsVertical() const { return bIsVertical; } + + EditPaM Clear(); + EditPaM RemoveText(); + EditPaM RemoveChars( EditPaM aPaM, USHORT nChars ); + EditPaM InsertText( EditPaM aPaM, const XubString& rStr ); + EditPaM InsertParaBreak( EditPaM aPaM, BOOL bKeepEndingAttribs ); + EditPaM InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem ); + EditPaM ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight ); + + String GetText( LineEnd eEnd ) const; + ULONG GetTextLen() const; + + XubString GetParaAsString( USHORT nNode ) const; + XubString GetParaAsString( ContentNode* pNode, USHORT nStartPos = 0, USHORT nEndPos = 0xFFFF, BOOL bResolveFields = TRUE ) const; + + inline EditPaM GetStartPaM() const; + inline EditPaM GetEndPaM() const; + + SfxItemPool& GetItemPool() { return *pItemPool; } + const SfxItemPool& GetItemPool() const { return *pItemPool; } + + void RemoveItemsFromPool( ContentNode* pNode ); + + void InsertAttrib( const SfxPoolItem& rItem, ContentNode* pNode, USHORT nStart, USHORT nEnd ); + void InsertAttrib( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem ); + void InsertAttribInSelection( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem ); + BOOL RemoveAttribs( ContentNode* pNode, USHORT nStart, USHORT nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, USHORT nWhich = 0 ); + void FindAttribs( ContentNode* pNode, USHORT nStartPos, USHORT nEndPos, SfxItemSet& rCurSet ); + + USHORT GetPos( ContentNode* pNode ) const { return ContentList::GetPos(pNode); } + ContentNode* SaveGetObject( USHORT nPos ) const { return ( nPos < Count() ) ? GetObject( nPos ) : 0; } + + static XubString GetSepStr( LineEnd eEnd ); +}; + +inline EditPaM EditDoc::GetStartPaM() const +{ + return EditPaM( GetObject( 0 ), 0 ); +} + +inline EditPaM EditDoc::GetEndPaM() const +{ + ContentNode* pLastNode = GetObject( Count()-1 ); + return EditPaM( pLastNode, pLastNode->Len() ); +} + +inline EditCharAttrib* GetAttrib( const CharAttribArray& rAttribs, USHORT nAttr ) +{ + return ( nAttr < rAttribs.Count() ) ? rAttribs[nAttr] : 0; +} + +BOOL CheckOrderedList( CharAttribArray& rAttribs, BOOL bStart ); + +// ------------------------------------------------------------------------- +// class EditEngineItemPool +// ------------------------------------------------------------------------- +class EditEngineItemPool : public SfxItemPool +{ +public: + EditEngineItemPool( BOOL bPersistenRefCounts ); + ~EditEngineItemPool(); + + virtual SvStream& Store( SvStream& rStream ) const; +}; + +}//end of namespace binfilter +#endif // _EDITDOC_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/editeng.hrc b/binfilter/bf_svx/source/editeng/editeng.hrc new file mode 100644 index 000000000000..7f97b8aaf20f --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editeng.hrc @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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 _EDITENG_HRC +#define _EDITENG_HRC + +#ifndef _SOLAR_HRC +#include <bf_svtools/solar.hrc> +#endif + +#define RID_EDITUNDO_DEL ( RID_EDIT_START + 0 ) +#define RID_EDITUNDO_MOVE ( RID_EDIT_START + 1 ) +#define RID_EDITUNDO_INSERT ( RID_EDIT_START + 2 ) +#define RID_EDITUNDO_REPLACE ( RID_EDIT_START + 3 ) +#define RID_EDITUNDO_SETATTRIBS ( RID_EDIT_START + 4 ) +#define RID_EDITUNDO_SETSTYLE ( RID_EDIT_START + 5 ) +#define RID_EDITUNDO_RESETATTRIBS ( RID_EDIT_START + 6 ) +#define RID_EDITUNDO_INDENT ( RID_EDIT_START + 7 ) +#define RID_EDITUNDO_TRANSLITERATE ( RID_EDIT_START + 8 ) + +#define RID_MENU_SPELL ( RID_EDIT_START + 10 ) + +#define MN_SPELLING 1 +#define MN_INSERT 2 +#define MN_IGNORE 3 +#define MN_AUTOCORR 4 +#define MN_WORDLANGUAGE 5 +#define MN_PARALANGUAGE 6 + +#define MN_ALTSTART 1000 +#define MN_AUTOSTART 2000 +#define MN_DICTSTART 3000 + + +#endif // _EDITENG_HRC diff --git a/binfilter/bf_svx/source/editeng/editobj2.hxx b/binfilter/bf_svx/source/editeng/editobj2.hxx new file mode 100644 index 000000000000..cb76c3b9bd1d --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editobj2.hxx @@ -0,0 +1,268 @@ +/* -*- 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 _EDITOBJ2_HXX +#define _EDITOBJ2_HXX + +#include <editobj.hxx> +#include <editdoc.hxx> + +#include <unotools/fontcvt.hxx> +class SfxStyleSheetPool; +namespace binfilter { + + + +class XEditAttribute +{ + friend class ContentInfo; // fuer DTOR + friend class BinTextObject; // fuer DTOR + +private: + const SfxPoolItem* pItem; + USHORT nStart; + USHORT nEnd; + + XEditAttribute(); + XEditAttribute( const XEditAttribute& rCopyFrom ); + + ~XEditAttribute(); + +public: + XEditAttribute( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + + const SfxPoolItem* GetItem() const { return pItem; } + + USHORT& GetStart() { return nStart; } + USHORT& GetEnd() { return nEnd; } + + USHORT GetStart() const { return nStart; } + USHORT GetEnd() const { return nEnd; } + + USHORT GetLen() const { return nEnd-nStart; } + + inline BOOL IsFeature(); +}; + +inline BOOL XEditAttribute::IsFeature() +{ + USHORT nWhich = pItem->Which(); + return ( ( nWhich >= EE_FEATURE_START ) && + ( nWhich <= EE_FEATURE_END ) ); +} + +typedef XEditAttribute* XEditAttributePtr; +SV_DECL_PTRARR( XEditAttributeListImpl, XEditAttributePtr, 0, 4 )//STRIP008 ; + +class XEditAttributeList : public XEditAttributeListImpl +{ +public: + XEditAttribute* FindAttrib( USHORT nWhich, USHORT nChar ) const; +}; + +struct XParaPortion +{ + long nHeight; + USHORT nFirstLineOffset; + + EditLineList aLines; + TextPortionList aTextPortions; +}; + +typedef XParaPortion* XParaPortionPtr; +SV_DECL_PTRARR( XBaseParaPortionList, XParaPortionPtr, 0, 4 )//STRIP008 ; + +class XParaPortionList : public XBaseParaPortionList +{ + ULONG nRefDevPtr; + OutDevType eRefDevType; + MapMode aRefMapMode; + ULONG nPaperWidth; + + +public: + XParaPortionList( OutputDevice* pRefDev, ULONG nPW ) : + aRefMapMode( pRefDev->GetMapMode() ) + { + nRefDevPtr = (ULONG)pRefDev; nPaperWidth = nPW; + eRefDevType = pRefDev->GetOutDevType(); + } + + ULONG GetRefDevPtr() const { return nRefDevPtr; } + ULONG GetPaperWidth() const { return nPaperWidth; } + OutDevType GetRefDevType() const { return eRefDevType; } + const MapMode& GetRefMapMode() const { return aRefMapMode; } +}; + +struct LoadStoreTempInfos +{ + ByteString aOrgString_Load; + + FontToSubsFontConverter hOldSymbolConv_Store; + BOOL bSymbolParagraph_Store; + + + LoadStoreTempInfos() { bSymbolParagraph_Store = FALSE; hOldSymbolConv_Store = NULL; } +}; + +class ContentInfo +{ + friend class BinTextObject; + +private: + String aText; + String aStyle; + XEditAttributeList aAttribs; + SfxStyleFamily eFamily; + SfxItemSet aParaAttribs; + + LoadStoreTempInfos* pTempLoadStoreInfos; + + ContentInfo( SfxItemPool& rPool ); + ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ); + +public: + ~ContentInfo(); + + const String& GetText() const { return aText; } + const String& GetStyle() const { return aStyle; } + const XEditAttributeList& GetAttribs() const { return aAttribs; } + const SfxItemSet& GetParaAttribs() const { return aParaAttribs; } + SfxStyleFamily GetFamily() const { return eFamily; } + + String& GetText() { return aText; } + String& GetStyle() { return aStyle; } + XEditAttributeList& GetAttribs() { return aAttribs; } + SfxItemSet& GetParaAttribs() { return aParaAttribs; } + SfxStyleFamily& GetFamily() { return eFamily; } + + LoadStoreTempInfos* GetLoadStoreTempInfos() const { return pTempLoadStoreInfos; } + void CreateLoadStoreTempInfos(); + void DestroyLoadStoreTempInfos(); + + +}; + +typedef ContentInfo* ContentInfoPtr; +SV_DECL_PTRARR( ContentInfoList, ContentInfoPtr, 1, 4 )//STRIP008 ; + +// MT 05/00: Sollte mal direkt EditTextObjekt werden => keine virtuellen Methoden mehr. + +class BinTextObject : public EditTextObject +{ +private: + ContentInfoList aContents; + SfxItemPool* pPool; + BOOL bOwnerOfPool; + XParaPortionList* pPortionInfo; + + sal_uInt32 nObjSettings; + USHORT nMetric; + USHORT nVersion; + USHORT nUserType; + USHORT nScriptType; + + BOOL bVertical; + BOOL bStoreUnicodeStrings; + +protected: + void DeleteContents(); + virtual void StoreData( SvStream& rOStream ) const; + virtual void CreateData( SvStream& rIStream ); + BOOL ImpChangeStyleSheets( const String& rOldName, SfxStyleFamily eOldFamily, + const String& rNewName, SfxStyleFamily eNewFamily ); + +public: + BinTextObject( SfxItemPool* pPool ); + BinTextObject( const BinTextObject& ); + virtual ~BinTextObject(); + + virtual EditTextObject* Clone() const; + + USHORT GetUserType() const; + void SetUserType( USHORT n ); + + + BOOL IsVertical() const; + void SetVertical( BOOL b ); + + void SetScriptType( USHORT nType ); + + USHORT GetVersion() const; // Solange der Outliner keine Recordlaenge speichert + void AdjustImportedLRSpaceItems( BOOL bTurnOfBullets ); + + ContentInfo* CreateAndInsertContent(); + XEditAttribute* CreateAttrib( const SfxPoolItem& rItem, USHORT nStart, USHORT nEnd ); + void DestroyAttrib( XEditAttribute* pAttr ); + + ContentInfoList& GetContents() { return aContents; } + const ContentInfoList& GetContents() const { return aContents; } + SfxItemPool* GetPool() const { return pPool; } + XParaPortionList* GetPortionInfo() const { return pPortionInfo; } + void SetPortionInfo( XParaPortionList* pP ) + { pPortionInfo = pP; } + + virtual USHORT GetParagraphCount() const; + virtual String GetText( USHORT nParagraph ) const; + virtual void Insert( const EditTextObject& rObj, USHORT nPara ); + + virtual void ClearPortionInfo(); + + + + + virtual void MergeParaAttribs( const SfxItemSet& rAttribs, USHORT nStart, USHORT nEnd ); + + virtual BOOL HasField( TypeId Type = NULL ) const; + + SfxItemSet GetParaAttribs( USHORT nPara ) const; + + virtual void GetStyleSheet( USHORT nPara, XubString& rName, SfxStyleFamily& eFamily ) const; + virtual void SetStyleSheet( USHORT nPara, const XubString& rName, const SfxStyleFamily& eFamily ); + virtual BOOL ChangeStyleSheets( const XubString& rOldName, SfxStyleFamily eOldFamily, + const String& rNewName, SfxStyleFamily eNewFamily ); + virtual void ChangeStyleSheetName( SfxStyleFamily eFamily, const XubString& rOldName, const XubString& rNewName ); + + void CreateData300( SvStream& rIStream ); + + BOOL HasMetric() const { return nMetric != 0xFFFF; } + USHORT GetMetric() const { return nMetric; } + void SetMetric( USHORT n ) { nMetric = n; } + + BOOL IsOwnerOfPool() const { return bOwnerOfPool; } + void StoreUnicodeStrings( BOOL b ) { bStoreUnicodeStrings = b; } + + void PrepareStore( SfxStyleSheetPool* pStyleSheetPool ); + void FinishStore(); + void FinishLoad( SfxStyleSheetPool* pStyleSheetPool ); +}; + +}//end of namespace binfilter +#endif // _EDITOBJ2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/editsel.hxx b/binfilter/bf_svx/source/editeng/editsel.hxx new file mode 100644 index 000000000000..1f9ced3625c3 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editsel.hxx @@ -0,0 +1,79 @@ +/* -*- 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 _EDITSEL_HXX +#define _EDITSEL_HXX + +#include <vcl/seleng.hxx> +namespace binfilter { + +class EditView; + +// ---------------------------------------------------------------------- +// class EditSelFunctionSet +// ---------------------------------------------------------------------- +class EditSelFunctionSet: public FunctionSet +{ +private: + EditView* pCurView; + +public: + EditSelFunctionSet(); + + virtual void BeginDrag(); + + virtual void CreateAnchor(); + virtual void DestroyAnchor(); + + virtual BOOL SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor = FALSE ); + + virtual BOOL IsSelectionAtPoint( const Point& rPointPixel ); + virtual void DeselectAtPoint( const Point& rPointPixel ); + virtual void DeselectAll(); + + void SetCurView( EditView* pView ) { pCurView = pView; } + EditView* GetCurView() { return pCurView; } +}; + +// ---------------------------------------------------------------------- +// class EditSelectionEngine +// ---------------------------------------------------------------------- +class EditSelectionEngine : public SelectionEngine +{ +private: + +public: + EditSelectionEngine(); + + void SetCurView( EditView* pNewView ); +}; + +}//end of namespace binfilter +#endif // _EDITSEL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/editstt2.hxx b/binfilter/bf_svx/source/editeng/editstt2.hxx new file mode 100644 index 000000000000..ea92d555b88f --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editstt2.hxx @@ -0,0 +1,134 @@ +/* -*- 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 _EDITSTT2_HXX +#define _EDITSTT2_HXX + +#include <editstat.hxx> +namespace binfilter { + +class InternalEditStatus : public EditStatus +{ + +public: + InternalEditStatus() { ; } + + void TurnOnFlags( ULONG nFlags ) + { nControlBits |= nFlags; } + + void TurnOffFlags( ULONG nFlags ) + { nControlBits &= ~nFlags; } + + void TurnOnStatusBits( ULONG nBits ) + { nStatusBits |= nBits; } + + void TurnOffStatusBits( ULONG nBits ) + { nStatusBits &= ~nBits; } + + + BOOL UseCharAttribs() const + { return ( ( nControlBits & EE_CNTRL_USECHARATTRIBS ) != 0 ); } + + BOOL NotifyCursorMovements() const + { return ( ( nControlBits & EE_CNTRL_CRSRLEFTPARA ) != 0 ); } + + BOOL UseIdleFormatter() const + { return ( ( nControlBits & EE_CNTRL_DOIDLEFORMAT) != 0 ); } + + BOOL AllowPasteSpecial() const + { return ( ( nControlBits & EE_CNTRL_PASTESPECIAL ) != 0 ); } + + BOOL DoAutoIndenting() const + { return ( ( nControlBits & EE_CNTRL_AUTOINDENTING ) != 0 ); } + + BOOL DoUndoAttribs() const + { return ( ( nControlBits & EE_CNTRL_UNDOATTRIBS ) != 0 ); } + + BOOL OneCharPerLine() const + { return ( ( nControlBits & EE_CNTRL_ONECHARPERLINE ) != 0 ); } + + BOOL IsOutliner() const + { return ( ( nControlBits & EE_CNTRL_OUTLINER ) != 0 ); } + + BOOL IsOutliner2() const + { return ( ( nControlBits & EE_CNTRL_OUTLINER2 ) != 0 ); } + + BOOL IsAnyOutliner() const + { return IsOutliner() || IsOutliner2(); } + + BOOL DoNotUseColors() const + { return ( ( nControlBits & EE_CNTRL_NOCOLORS ) != 0 ); } + + BOOL AllowBigObjects() const + { return ( ( nControlBits & EE_CNTRL_ALLOWBIGOBJS ) != 0 ); } + + BOOL DoStretch() const + { return ( ( nControlBits & EE_CNTRL_STRETCHING ) != 0 ); } + + BOOL AutoPageSize() const + { return ( ( nControlBits & EE_CNTRL_AUTOPAGESIZE ) != 0 ); } + BOOL AutoPageWidth() const + { return ( ( nControlBits & EE_CNTRL_AUTOPAGESIZEX ) != 0 ); } + BOOL AutoPageHeight() const + { return ( ( nControlBits & EE_CNTRL_AUTOPAGESIZEY ) != 0 ); } + + BOOL MarkFields() const + { return ( ( nControlBits & EE_CNTRL_MARKFIELDS ) != 0 ); } + + BOOL DoRestoreFont() const + { return ( ( nControlBits & EE_CNTRL_RESTOREFONT ) != 0 ); } + + BOOL DoImportRTFStyleSheets() const + { return ( ( nControlBits & EE_CNTRL_RTFSTYLESHEETS ) != 0 ); } + + BOOL DoDrawRedLines() const + { return ( ( nControlBits & EE_CNTRL_NOREDLINES ) == 0 ); } + + BOOL DoAutoCorrect() const + { return ( ( nControlBits & EE_CNTRL_AUTOCORRECT ) != 0 ); } + + BOOL DoAutoComplete() const + { return ( ( nControlBits & EE_CNTRL_AUTOCOMPLETE ) != 0 ); } + + BOOL DoTabIndenting() const + { return ( ( nControlBits & EE_CNTRL_TABINDENTING ) != 0 ); } + + BOOL DoFormat100() const + { return ( ( nControlBits & EE_CNTRL_FORMAT100 ) != 0 ); } + + BOOL ULSpaceSummation() const + { return ( ( nControlBits & EE_CNTRL_ULSPACESUMMATION ) != 0 ); } + + BOOL ULSpaceFirstParagraph() const + { return ( ( nControlBits & EE_CNTRL_ULSPACEFIRSTPARA ) != 0 ); } +}; + +}//end of namespace binfilter +#endif // _EDITSTT2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/editundo.hxx b/binfilter/bf_svx/source/editeng/editundo.hxx new file mode 100644 index 000000000000..99ef04022524 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/editundo.hxx @@ -0,0 +1,157 @@ +/* -*- 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 _EDITUNDO_HXX +#define _EDITUNDO_HXX + +#include <editdoc.hxx> +#include <editund2.hxx> +#include <editdata.hxx> +namespace binfilter { + +#define UNDO_NOACTION 0 +#define UNDO_NEWUNDO 1 +#define UNDO_UNDOSDELETED 2 +#define UNDO_EMPTYGROUPDELETED 3 +#define UNDO_INVALIDEND 4 + +class ImpEditEngine; +class EditView; + +// ----------------------------------------------------------------------- +// EditUndoInsertChars +// ------------------------------------------------------------------------ +class EditUndoInsertChars : public EditUndo +{ +private: + EPaM aEPaM; + String aText; + +public: + TYPEINFO(); + EditUndoInsertChars( ImpEditEngine* pImpEE, const EPaM& rEPaM, const String& rStr ); + + const EPaM& GetEPaM() { return aEPaM; } + String& GetStr() { return aText; } + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(); + + virtual BOOL Merge( SfxUndoAction *pNextAction ); +}; + +// ----------------------------------------------------------------------- +// EditUndoRemoveChars +// ------------------------------------------------------------------------ + +// ----------------------------------------------------------------------- +// EditUndoInsertFeature +// ------------------------------------------------------------------------ +class EditUndoInsertFeature : public EditUndo +{ +private: + EPaM aEPaM; + SfxPoolItem* pFeature; + +public: + EditUndoInsertFeature( ImpEditEngine* pImpEE, const EPaM& rEPaM, + const SfxPoolItem& rFeature); + ~EditUndoInsertFeature(); + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(); +}; + +// ----------------------------------------------------------------------- +// EditUndoMoveParagraphs +// ------------------------------------------------------------------------ + +// ----------------------------------------------------------------------- +// EditUndoSetStyleSheet +// ------------------------------------------------------------------------ +class EditUndoSetStyleSheet: public EditUndo +{ +private: + USHORT nPara; + XubString aPrevName; + XubString aNewName; + SfxStyleFamily ePrevFamily; + SfxStyleFamily eNewFamily; + SfxItemSet aPrevParaAttribs; + +public: + + EditUndoSetStyleSheet( ImpEditEngine* pImpEE, USHORT nPara, + const XubString& rPrevName, SfxStyleFamily ePrevFamily, + const XubString& rNewName, SfxStyleFamily eNewFamily, + const SfxItemSet& rPrevParaAttribs ); + ~EditUndoSetStyleSheet(); + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(); +}; + +// ----------------------------------------------------------------------- +// EditUndoSetParaAttribs +// ------------------------------------------------------------------------ +class EditUndoSetParaAttribs: public EditUndo +{ +private: + USHORT nPara; + SfxItemSet aPrevItems; + SfxItemSet aNewItems; + +public: + EditUndoSetParaAttribs( ImpEditEngine* pImpEE, USHORT nPara, const SfxItemSet& rPrevItems, const SfxItemSet& rNewItems ); + ~EditUndoSetParaAttribs(); + + virtual void Undo(); + virtual void Redo(); + virtual void Repeat(); +}; + +// ----------------------------------------------------------------------- +// EditUndoSetAttribs +// ------------------------------------------------------------------------ + +// ----------------------------------------------------------------------- +// EditUndoTransliteration +// ------------------------------------------------------------------------ + +// ----------------------------------------------------------------------- +// EditUndoMarkSelection +// ------------------------------------------------------------------------ + + +}//end of namespace binfilter +#endif // _EDITUNDO_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/eerdll2.hxx b/binfilter/bf_svx/source/editeng/eerdll2.hxx new file mode 100644 index 000000000000..d3ac745ab5fb --- /dev/null +++ b/binfilter/bf_svx/source/editeng/eerdll2.hxx @@ -0,0 +1,67 @@ +/* -*- 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 _EERDLL2_HXX +#define _EERDLL2_HXX + +#include <forbiddencharacterstable.hxx> +#include <rtl/ref.hxx> +namespace binfilter { + +class SfxPoolItem; +class SvxAutoCorrect; + +class GlobalEditData +{ +private: + SfxPoolItem** ppDefItems; + OutputDevice* pStdRefDevice; + + Link aGetAutoCorrectHdl; + + rtl::Reference<SvxForbiddenCharactersTable> xForbiddenCharsTable; + +public: + GlobalEditData(); + ~GlobalEditData(); + + SfxPoolItem** GetDefItems(); + OutputDevice* GetStdRefDevice(); + + void SetGetAutoCorrectHdl( const Link& rHdl ) { aGetAutoCorrectHdl = rHdl; } + SvxAutoCorrect* GetAutoCorrect() const { return (SvxAutoCorrect*) aGetAutoCorrectHdl.Call( NULL ); } + + rtl::Reference<SvxForbiddenCharactersTable> GetForbiddenCharsTable(); + void SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars ) { xForbiddenCharsTable = xForbiddenChars; } +}; + + +}//end of namespace binfilter +#endif //_EERDLL2_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/impedit.hxx b/binfilter/bf_svx/source/editeng/impedit.hxx new file mode 100644 index 000000000000..76b1a93fa1b2 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/impedit.hxx @@ -0,0 +1,826 @@ +/* -*- 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 _IMPEDIT_HXX +#define _IMPEDIT_HXX + +#include <editdoc.hxx> +#include <editsel.hxx> +#include <editundo.hxx> +#include <editobj2.hxx> +#include <editstt2.hxx> +#include <editdata.hxx> + +#include <vcl/virdev.hxx> +#include <vcl/cursor.hxx> +#include <vcl/dndhelp.hxx> + +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/i18n/XBreakIterator.hpp> +#include <com/sun/star/i18n/CharacterIteratorMode.hpp> +#include <com/sun/star/i18n/WordType.hpp> + +#include <bf_svtools/colorcfg.hxx> +#include <rtl/ref.hxx> + +namespace binfilter { +class SvtCTLOptions; +class SvKeyValueIterator; +class SvUShorts; + +DBG_NAMEEX( EditView )//STRIP008 +DBG_NAMEEX( EditEngine )//STRIP008 + +#define PIMPEE pImpEditView->pEditEngine->pImpEditEngine + +#define DEL_LEFT 1 +#define DEL_RIGHT 2 +#define TRAVEL_X_DONTKNOW 0xFFFFFFFF +#define CURSOR_BIDILEVEL_DONTKNOW 0xFFFF +#define MAXCHARSINPARA 0x3FFF-CHARPOSGROW // Max 16K, because WYSIWYG array + +#define ATTRSPECIAL_WHOLEWORD 1 +#define ATTRSPECIAL_EDGE 2 + +#define GETCRSR_TXTONLY 0x0001 +#define GETCRSR_STARTOFLINE 0x0002 +#define GETCRSR_ENDOFLINE 0x0004 +#define GETCRSR_PREFERPORTIONSTART 0x0008 + +#define LINE_SEP 0x0A + +typedef EENotify* EENotifyPtr; +SV_DECL_PTRARR_DEL( NotifyList, EENotifyPtr, 1, 1 )//STRIP008 ; // IMPL is in outliner.cxx, move to EE later and share declaration, or use BlockNotifications from EE directly + + +class EditView; +class EditEngine; +class EditUndoRemoveChars; +class SvxFontTable; +class SvxColorList; + +class SvxLRSpaceItem; +class TextRanger; +class SvxForbiddenCharactersTable; + + +}//end of namespace binfilter +namespace com { +namespace sun { +namespace star { +namespace datatransfer { +namespace clipboard { + class XClipboard; +}}}}} + +namespace binfilter { + +struct ImplIMEInfos +{ + String aOldTextAfterStartPos; + sal_uInt16* pAttribs; + EditPaM aPos; + sal_uInt16 nLen; + sal_Bool bCursor; + sal_Bool bWasCursorOverwrite; +}; + + +struct FormatterFontMetric +{ + sal_uInt16 nMaxAscent; + sal_uInt16 nMaxDescent; + + FormatterFontMetric() { nMaxAscent = 0; nMaxDescent = 0; /* nMinLeading = 0xFFFF; */ } + sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; } +}; + +// ---------------------------------------------------------------------- +// class ImpEditView +// ---------------------------------------------------------------------- +class ImpEditView : public vcl::unohelper::DragAndDropClient +{ + friend class EditView; + friend class EditEngine; + friend class ImpEditEngine; + +private: + EditView* pEditView; + Cursor* pCursor; + Color* pBackgroundColor; + EditEngine* pEditEngine; + Window* pOutWin; + Pointer* pPointer; + + long nInvMore; + ULONG nControl; + sal_uInt32 nTravelXPos; + sal_uInt16 nExtraCursorFlags; + sal_uInt16 nCursorBidiLevel; + sal_uInt16 nScrollDiffX; + sal_Bool bReadOnly; + sal_Bool bClickedInSelection; + sal_Bool bActiveDragAndDropListener; + + Point aAnchorPoint; + Rectangle aOutArea; + Point aVisDocStartPos; + EESelectionMode eSelectionMode; + EditSelection aEditSelection; + EVAnchorMode eAnchorMode; + +protected: + + // DragAndDropClient + + + +public: + ~ImpEditView(); + + EditView* GetEditViewPtr() { return pEditView; } + + sal_uInt16 GetScrollDiffX() const { return nScrollDiffX; } + void SetScrollDiffX( sal_uInt16 n ) { nScrollDiffX = n; } + + sal_uInt16 GetCursorBidiLevel() const { return nCursorBidiLevel; } + void SetCursorBidiLevel( sal_uInt16 n ) { nCursorBidiLevel = n; } + + Point GetDocPos( const Point& rWindowPos ) const; + Point GetWindowPos( const Point& rDocPos ) const; + Rectangle GetWindowPos( const Rectangle& rDocPos ) const; + + const Rectangle& GetOutputArea() const { return aOutArea; } + + BOOL IsVertical() const; + + void SetVisDocStartPos( const Point& rPos ) { aVisDocStartPos = rPos; } + const Point& GetVisDocStartPos() const { return aVisDocStartPos; } + + long GetVisDocLeft() const { return aVisDocStartPos.X(); } + long GetVisDocTop() const { return aVisDocStartPos.Y(); } + long GetVisDocRight() const { return aVisDocStartPos.X() + ( !IsVertical() ? aOutArea.GetWidth() : aOutArea.GetHeight() ); } + long GetVisDocBottom() const { return aVisDocStartPos.Y() + ( !IsVertical() ? aOutArea.GetHeight() : aOutArea.GetWidth() ); } + Rectangle GetVisDocArea() const; + + EditSelection& GetEditSelection() { return aEditSelection; } + void SetEditSelection( const EditSelection& rEditSelection ); + sal_Bool HasSelection() const { return aEditSelection.HasRange(); } + + void DrawSelection() { DrawSelection( aEditSelection ); } + void DrawSelection( EditSelection, Region* pRegion = NULL ); + + Window* GetWindow() const { return pOutWin; } + + EESelectionMode GetSelectionMode() const { return eSelectionMode; } + + inline void SetPointer( const Pointer& rPointer ); + inline const Pointer& GetPointer(); + + inline void SetCursor( const Cursor& rCursor ); + inline Cursor* GetCursor(); + + + EVAnchorMode GetAnchorMode() const { return eAnchorMode; } + void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, BOOL test ); + void ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, USHORT nShowCursorFlags = 0 ); + + sal_Bool IsInsertMode() const { return ( ( nControl & EV_CNTRL_OVERWRITE ) == 0 ); } + + void EnablePaste( sal_Bool bEnable ) { SetFlags( nControl, EV_CNTRL_ENABLEPASTE, bEnable ); } + sal_Bool IsPasteEnabled() const { return ( ( nControl & EV_CNTRL_ENABLEPASTE ) != 0 ); } + + sal_Bool DoSingleLinePaste() const { return ( ( nControl & EV_CNTRL_SINGLELINEPASTE ) != 0 ); } + sal_Bool DoAutoScroll() const { return ( ( nControl & EV_CNTRL_AUTOSCROLL ) != 0 ); } + sal_Bool DoBigScroll() const { return ( ( nControl & EV_CNTRL_BIGSCROLL ) != 0 ); } + sal_Bool DoAutoSize() const { return ( ( nControl & EV_CNTRL_AUTOSIZE ) != 0 ); } + sal_Bool DoAutoWidth() const { return ( ( nControl & EV_CNTRL_AUTOSIZEX) != 0 ); } + sal_Bool DoAutoHeight() const { return ( ( nControl & EV_CNTRL_AUTOSIZEY) != 0 ); } + sal_Bool DoInvalidateMore() const { return ( ( nControl & EV_CNTRL_INVONEMORE ) != 0 ); } + + const Color& GetBackgroundColor() const { + return ( pBackgroundColor ? *pBackgroundColor : pOutWin->GetBackground().GetColor() ); } + + // Ggf. mehr als OutputArea invalidieren, fuer den DrawingEngine-Textrahmen... + void SetInvalidateMore( sal_uInt16 nPixel ) { nInvMore = nPixel; } + sal_uInt16 GetInvalidateMore() const { return (sal_uInt16)nInvMore; } +}; + +// ---------------------------------------------------------------------- +// ImpEditEngine +// ---------------------------------------------------------------------- + +typedef EditView* EditViewPtr; +SV_DECL_PTRARR( EditViews, EditViewPtr, 0, 1 )//STRIP008 ; + +class ImpEditEngine : public SfxListener +{ + // Die Undos muessen direkt manipulieren ( private-Methoden ), + // damit keine neues Undos eingefuegt werden! + friend class EditUndoInsertChars; + friend class EditUndoRemoveChars; + friend class EditUndoDelContent; + friend class EditUndoConnectParas; + friend class EditUndoInsertFeature; + friend class EditUndoMoveParagraphs; + + friend class EditView; + friend class ImpEditView; + friend class EditEngine; // Fuer Zugriff auf Imp-Methoden + friend class EditRTFParser; // Fuer Zugriff auf Imp-Methoden + friend class EditHTMLParser; // Fuer Zugriff auf Imp-Methoden + friend class EdtAutoCorrDoc; // Fuer Zugriff auf Imp-Methoden + friend class EditDbg; // DebugRoutinen + +private: + + // ================================================================ + // Daten... + // ================================================================ + + // Dokument-Spezifische Daten... + ParaPortionList aParaPortionList; // Formatierung + Size aPaperSize; // Layout + Size aMinAutoPaperSize; // Layout ? + Size aMaxAutoPaperSize; // Layout ? + EditDoc aEditDoc; // Dokumenteninhalt + + // Engine-Spezifische Daten.... + EditEngine* pEditEngine; + EditViews aEditViews; + EditView* pActiveView; + TextRanger* pTextRanger; + + SfxStyleSheetPool* pStylePool; + SfxItemPool* pTextObjectPool; + + VirtualDevice* pVirtDev; + OutputDevice* pRefDev; + + ColorConfig* pColorConfig; + SvtCTLOptions* pCTLOptions; + + SfxItemSet* pEmptyItemSet; + EditUndoManager* pUndoManager; + ESelection* pUndoMarkSelection; + + ImplIMEInfos* mpIMEInfos; + + NotifyList aNotifyCache; + + XubString aWordDelimiters; + XubString aGroupChars; + + EditSelFunctionSet aSelFuncSet; + EditSelectionEngine aSelEngine; + + Color maBackgroundColor; + + sal_uInt32 nBlockNotifications; + sal_uInt16 nStretchX; + sal_uInt16 nStretchY; + + USHORT nAsianCompressionMode; + BOOL bKernAsianPunctuation; + + EEHorizontalTextDirection eDefaultHorizontalTextDirection; + + sal_uInt16 nBigTextObjectStart; + ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > xBI; + + XubString aAutoCompleteText; + + InternalEditStatus aStatus; + + LanguageType eDefLanguage; + + sal_Bool bIsFormatting; + sal_Bool bFormatted; + sal_Bool bInSelection; + sal_Bool bIsInUndo; + sal_Bool bUpdate; + sal_Bool bUndoEnabled; + sal_Bool bOwnerOfRefDev; + sal_Bool bDowning; + sal_Bool bUseAutoColor; + sal_Bool bForceAutoColor; + sal_Bool bCallParaInsertedOrDeleted; + + // Fuer Formatierung / Update.... + DeletedNodesList aDeletedNodes; + Rectangle aInvalidRec; + sal_uInt32 nCurTextHeight; + sal_uInt16 nOnePixelInRef; + + // Wenn an einer Stelle erkannt wird, dass der StatusHdl gerufen werden + // muss, dies aber nicht sofort geschehen darf (kritischer Abschnitt): + Link aNotifyHdl; + Link aImportHdl; + Link aBeginMovingParagraphsHdl; + Link aEndMovingParagraphsHdl; + Link aBeginPasteOrDropHdl; + Link aEndPasteOrDropHdl; + Link aModifyHdl; + + rtl::Reference<SvxForbiddenCharactersTable> xForbiddenCharsTable; + + + // ================================================================ + // Methoden... + // ================================================================ + + void CursorMoved( ContentNode* pPrevNode ); + void ParaAttribsChanged( ContentNode* pNode ); + void TextModified(); + void CalcHeight( ParaPortion* pPortion ); + + // ggf. lieber inline, aber so einiges... + void InsertUndo( EditUndo* pUndo, sal_Bool bTryMerge = sal_False ); + void ResetUndoManager(); + sal_Bool HasUndoManager() const { return pUndoManager ? sal_True : sal_False; } + + + EditPaM GetPaM( Point aDocPos, sal_Bool bSmart = sal_True ); + EditPaM GetPaM( ParaPortion* pPortion, Point aPos, sal_Bool bSmart = sal_True ); + long GetPortionXOffset( ParaPortion* pParaPortion, EditLine* pLine, USHORT nTextPortion ); + USHORT GetChar( ParaPortion* pParaPortion, EditLine* pLine, long nX, BOOL bSmart = TRUE ); + Range GetInvalidYOffsets( ParaPortion* pPortion ); + Range GetLineXPosStartEnd( ParaPortion* pParaPortion, EditLine* pLine ); + + void SetParaAttrib( BYTE nFunc, EditSelection aSel, sal_uInt16 nValue ); + sal_uInt16 GetParaAttrib( BYTE nFunc, EditSelection aSel ); + void SetCharAttrib( EditSelection aSel, const SfxPoolItem& rItem ); + + EditTextObject* CreateBinTextObject( EditSelection aSelection, SfxItemPool*, sal_Bool bAllowBigObjects = sal_False, sal_uInt16 nBigObjStart = 0 ) const; + void StoreBinTextObject( SvStream& rOStream, BinTextObject& rTextObject ); + EditSelection InsertBinTextObject( BinTextObject&, EditPaM aPaM ); + + EditPaM Clear(); + EditPaM RemoveText(); + EditPaM RemoveText( EditSelection aEditSelection ); + sal_Bool CreateLines( USHORT nPara, sal_uInt32 nStartPosY ); + void CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uInt32 nStartPosY ); + sal_Bool FinishCreateLines( ParaPortion* pParaPortion ); + void CalcCharPositions( ParaPortion* pParaPortion ); + void CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStartPos /*, sal_Bool bCreateBlockPortions */ ); + void RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars ); + sal_uInt16 SplitTextPortion( ParaPortion* pParaPortion, sal_uInt16 nPos, EditLine* pCurLine = 0 ); + void SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut = NULL, sal_uInt16 nIgnoreWhich = 0 ); + void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont ); + void CheckAutoPageSize(); + + void ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate ); + void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace ); + EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, sal_Bool bBackward = sal_False ); + EditPaM ImpDeleteSelection( EditSelection aEditSelection); + EditPaM ImpInsertParaBreak( const EditPaM& rPaM, sal_Bool bKeepEndingAttribs = sal_True ); + EditPaM ImpInsertText( EditSelection aCurEditSelection, const String& rStr ); + EditPaM ImpInsertFeature( EditSelection aEditSelection, const SfxPoolItem& rItem ); + void ImpRemoveChars( const EditPaM& rPaM, sal_uInt16 nChars, EditUndoRemoveChars* pCurUndo = 0 ); + + EditPaM ImpFastInsertText( EditPaM aPaM, const String& rStr ); + EditPaM ImpFastInsertParagraph( sal_uInt16 nPara ); + + sal_Bool ImpCheckRefMapMode(); + + BOOL ImplHasText() const; + + void ImpFindKashidas( ContentNode* pNode, USHORT nStart, USHORT nEnd, SvUShorts& rArray ); + + + + EditPaM WordRight( const EditPaM& rPaM, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES ); + EditSelection SelectWord( const EditSelection& rCurSelection, sal_Int16 nWordType = ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, BOOL bAcceptStartOfWord = TRUE ); + EditPaM CursorVisualLeftRight( EditView* pEditView, const EditPaM& rPaM, USHORT nCharacterIteratorMode, BOOL bToLeft ); + EditPaM CursorVisualStartEnd( EditView* pEditView, const EditPaM& rPaM, BOOL bStart ); + + + void InitScriptTypes( USHORT nPara ); + USHORT GetScriptType( const EditPaM& rPaM, USHORT* pEndPos = NULL ) const; + USHORT GetScriptType( const EditSelection& rSel ) const; + BOOL IsScriptChange( const EditPaM& rPaM ) const; + BOOL HasScriptType( USHORT nPara, USHORT nType ) const; + + + void ImplInitLayoutMode( OutputDevice* pOutDev, USHORT nPara, USHORT nIndex ); + + + + inline short GetXValue( short nXValue ) const; + inline sal_uInt16 GetXValue( sal_uInt16 nXValue ) const; + inline long GetXValue( long nXValue ) const; + + inline short GetYValue( short nYValue ) const; + inline sal_uInt16 GetYValue( sal_uInt16 nYValue ) const; + + + + void SetBackgroundColor( const Color& rColor ) { maBackgroundColor = rColor; } + Color GetBackgroundColor() const { return maBackgroundColor; } + + Color GetAutoColor() const; + void EnableAutoColor( BOOL b ) { bUseAutoColor = b; } + BOOL IsAutoColorEnabled() const { return bUseAutoColor; } + void ForceAutoColor( BOOL b ) { bForceAutoColor = b; } + BOOL IsForceAutoColor() const { return bForceAutoColor; } + + inline VirtualDevice* GetVirtualDevice( const MapMode& rMapMode ); + inline void EraseVirtualDevice(); + + void CheckIdleFormatter(); + + inline ParaPortion* FindParaPortion( ContentNode* pNode ) const; + + void SetValidPaperSize( const Size& rSz ); + + ::com::sun::star::uno::Reference < ::com::sun::star::i18n::XBreakIterator > ImplGetBreakIterator(); + + + +protected: + +public: + ImpEditEngine( EditEngine* pEditEngine, SfxItemPool* pPool ); + ~ImpEditEngine(); + + void InitDoc( BOOL bKeepParaAttribs ); + EditDoc& GetEditDoc() { return aEditDoc; } + const EditDoc& GetEditDoc() const { return aEditDoc; } + + inline EditUndoManager& GetUndoManager(); + + void SetUpdateMode( sal_Bool bUp, EditView* pCurView = 0, sal_Bool bForceUpdate = sal_False ); + sal_Bool GetUpdateMode() const { return bUpdate; } + + const ParaPortionList& GetParaPortions() const { return aParaPortionList; } + ParaPortionList& GetParaPortions() { return aParaPortionList; } + EditViews& GetEditViews() { return aEditViews; } + + const Size& GetPaperSize() const { return aPaperSize; } + void SetPaperSize( const Size& rSz ) { aPaperSize = rSz; } + + void SetVertical( BOOL bVertical ); + BOOL IsVertical() const { return GetEditDoc().IsVertical(); } + + void SetDefaultHorizontalTextDirection( EEHorizontalTextDirection eHTextDir ) { eDefaultHorizontalTextDirection = eHTextDir; } + EEHorizontalTextDirection GetDefaultHorizontalTextDirection() const { return eDefaultHorizontalTextDirection; } + + + void InitWritingDirections( USHORT nPara ); + BOOL IsRightToLeft( USHORT nPara ) const; + BYTE GetRightToLeft( USHORT nPara, USHORT nChar, USHORT* pStart = NULL, USHORT* pEnd = NULL ); + BOOL HasDifferentRTLLevels( const ContentNode* pNode ); + + void SetTextRanger( TextRanger* pRanger ); + TextRanger* GetTextRanger() const { return pTextRanger; } + + const Size& GetMinAutoPaperSize() const { return aMinAutoPaperSize; } + void SetMinAutoPaperSize( const Size& rSz ) { aMinAutoPaperSize = rSz; } + + const Size& GetMaxAutoPaperSize() const { return aMaxAutoPaperSize; } + void SetMaxAutoPaperSize( const Size& rSz ) { aMaxAutoPaperSize = rSz; } + + void FormatDoc(); + void FormatFullDoc(); + void UpdateViews( EditView* pCurView = 0 ); + void Paint( ImpEditView* pView, const Rectangle& rRect, sal_Bool bUseVirtDev = sal_False ); + void Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly = sal_False, short nOrientation = 0 ); + + + EditSelectionEngine& GetSelEngine() { return aSelEngine; } + XubString GetSelected( const EditSelection& rSel, const LineEnd eParaSep = LINEEND_LF ) const; + + const SfxItemSet& GetEmptyItemSet(); + + void UpdateSelections(); + + void EnableUndo( sal_Bool bEnable ); + sal_Bool IsUndoEnabled() { return bUndoEnabled; } + void SetUndoMode( sal_Bool b ) { bIsInUndo = b; } + sal_Bool IsInUndo() { return bIsInUndo; } + + void SetCallParaInsertedOrDeleted( sal_Bool b ) { bCallParaInsertedOrDeleted = b; } + sal_Bool IsCallParaInsertedOrDeleted() const { return bCallParaInsertedOrDeleted; } + + sal_Bool IsFormatted() const { return bFormatted; } + sal_Bool IsFormatting() const { return bIsFormatting; } + + void SetText( const String& rText ); + EditPaM InsertLineBreak( EditSelection aEditSelection ); + EditPaM InsertField( EditSelection aEditSelection, const SvxFieldItem& rFld ); + sal_Bool UpdateFields(); + + + EditTextObject* CreateTextObject(); + EditTextObject* CreateTextObject( EditSelection aSel ); + void SetText( const EditTextObject& rTextObject ); + EditSelection InsertText( const EditTextObject& rTextObject, EditSelection aSel ); + + + + sal_uInt32 CalcTextHeight(); + sal_uInt32 GetTextHeight() const; + sal_uInt32 CalcTextWidth( BOOL bIgnoreExtraSpace ); + sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, BOOL bIgnoreExtraSpace ); + sal_uInt16 GetLineCount( sal_uInt16 nParagraph ) const; + + SfxItemSet GetAttribs( USHORT nPara, USHORT nStart, USHORT nEnd, sal_uInt8 nFlags = 0xFF ) const; + SfxItemSet GetAttribs( EditSelection aSel, BOOL bOnlyHardAttrib = FALSE ); + void SetAttribs( EditSelection aSel, const SfxItemSet& rSet, BYTE nSpecial = 0 ); + void RemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich = 0, sal_Bool bRemoveFeatures = sal_False ); + + void SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ); + const SfxItemSet& GetParaAttribs( sal_uInt16 nPara ) const; + + sal_Bool HasParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const; + const SfxPoolItem& GetParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const; + + + sal_Bool IsModified() const { return aEditDoc.IsModified(); } + void SetModifyFlag( sal_Bool b ) { aEditDoc.SetModified( b ); } + void SetModifyHdl( const Link& rLink ) { aModifyHdl = rLink; } + Link GetModifyHdl() const { return aModifyHdl; } + + + sal_Bool IsInSelectionMode() { return bInSelection; } + + +// Fuer Undo/Redo + +// OV-Special + EditPaM InsertParagraph( sal_uInt16 nPara ); + EditSelection* SelectParagraph( sal_uInt16 nPara ); + + void SetNotifyHdl( const Link& rLink ) { aNotifyHdl = rLink; } + Link GetNotifyHdl() const { return aNotifyHdl; } + + void FormatAndUpdate( EditView* pCurView = 0 ); + inline void IdleFormatAndUpdate( EditView* pCurView = 0 ); + + ColorConfig& GetColorConfig(); + BOOL IsVisualCursorTravelingEnabled(); + BOOL DoVisualCursorTraveling( const ContentNode* pNode ); + + EditSelection ConvertSelection( sal_uInt16 nStartPara, sal_uInt16 nStartPos, sal_uInt16 nEndPara, sal_uInt16 nEndPos ) const; + inline EPaM CreateEPaM( const EditPaM& rPaM ); + inline EditPaM CreateEditPaM( const EPaM& rEPaM ); + inline ESelection CreateESel( const EditSelection& rSel ); + inline EditSelection CreateSel( const ESelection& rSel ); + + + void SetStyleSheetPool( SfxStyleSheetPool* pSPool ); + SfxStyleSheetPool* GetStyleSheetPool() const { return pStylePool; } + + void SetStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pStyle ); + SfxStyleSheet* GetStyleSheet( sal_uInt16 nPara ) const; + + + OutputDevice* GetRefDevice() const { return pRefDev; } + void SetRefDevice( OutputDevice* pRefDef ); + + const MapMode& GetRefMapMode() { return pRefDev->GetMapMode(); } + void SetRefMapMode( const MapMode& rMapMode ); + + InternalEditStatus& GetStatus() { return aStatus; } + void CallStatusHdl(); + + void EnterBlockNotifications(); + void LeaveBlockNotifications(); + + void UndoActionStart( sal_uInt16 nId ); + void UndoActionEnd( sal_uInt16 nId ); + + EditView* GetActiveView() const { return pActiveView; } + void SetActiveView( EditView* pView ); + + void SetDefaultLanguage( LanguageType eLang ) { eDefLanguage = eLang; } + LanguageType GetDefaultLanguage() const { return eDefLanguage; } + + LanguageType GetLanguage( const EditSelection rSelection ) const; + LanguageType GetLanguage( const EditPaM& rPaM, USHORT* pEndPos = NULL ) const; + ::com::sun::star::lang::Locale GetLocale( const EditPaM& rPaM ) const; + + + + void SetEditTextObjectPool( SfxItemPool* pP ) { pTextObjectPool = pP; } + SfxItemPool* GetEditTextObjectPool() const { return pTextObjectPool; } + + const SvxLRSpaceItem& GetLRSpaceItem( ContentNode* pNode ); + SvxAdjust GetJustification( USHORT nPara ) const; + + void SetCharStretching( sal_uInt16 nX, sal_uInt16 nY ); + inline void GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ); + + void SetBigTextObjectStart( sal_uInt16 nStartAtPortionCount ) { nBigTextObjectStart = nStartAtPortionCount; } + sal_uInt16 GetBigTextObjectStart() const { return nBigTextObjectStart; } + + inline EditEngine* GetEditEnginePtr() const { return pEditEngine; } + + void SetAsianCompressionMode( USHORT n ); + USHORT GetAsianCompressionMode() const { return nAsianCompressionMode; } + + void SetKernAsianPunctuation( BOOL b ); + BOOL IsKernAsianPunctuation() const { return bKernAsianPunctuation; } + + rtl::Reference<SvxForbiddenCharactersTable> GetForbiddenCharsTable( BOOL bGetInternal = TRUE ) const; + void SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars ); +}; + +inline EPaM ImpEditEngine::CreateEPaM( const EditPaM& rPaM ) +{ + ContentNode* pNode = rPaM.GetNode(); + return EPaM( aEditDoc.GetPos( pNode ), rPaM.GetIndex() ); +} + +inline EditPaM ImpEditEngine::CreateEditPaM( const EPaM& rEPaM ) +{ + DBG_ASSERT( rEPaM.nPara < aEditDoc.Count(), "CreateEditPaM: Ungueltiger Absatz" ); + DBG_ASSERT( aEditDoc[ rEPaM.nPara ]->Len() >= rEPaM.nIndex, "CreateEditPaM: Ungueltiger Index" ); + return EditPaM( aEditDoc[ rEPaM.nPara], rEPaM.nIndex ); +} + +inline ESelection ImpEditEngine::CreateESel( const EditSelection& rSel ) +{ + ContentNode* pStartNode = rSel.Min().GetNode(); + ContentNode* pEndNode = rSel.Max().GetNode(); + ESelection aESel; + aESel.nStartPara = aEditDoc.GetPos( pStartNode ); + aESel.nStartPos = rSel.Min().GetIndex(); + aESel.nEndPara = aEditDoc.GetPos( pEndNode ); + aESel.nEndPos = rSel.Max().GetIndex(); + return aESel; +} + +inline EditSelection ImpEditEngine::CreateSel( const ESelection& rSel ) +{ + DBG_ASSERT( rSel.nStartPara < aEditDoc.Count(), "CreateSel: Ungueltiger Start-Absatz" ); + DBG_ASSERT( rSel.nEndPara < aEditDoc.Count(), "CreateSel: Ungueltiger End-Absatz" ); + EditSelection aSel; + aSel.Min().SetNode( aEditDoc[ rSel.nStartPara ] ); + aSel.Min().SetIndex( rSel.nStartPos ); + aSel.Max().SetNode( aEditDoc[ rSel.nEndPara ] ); + aSel.Max().SetIndex( rSel.nEndPos ); + return aSel; +} + +inline VirtualDevice* ImpEditEngine::GetVirtualDevice( const MapMode& rMapMode ) +{ + if ( !pVirtDev ) + pVirtDev = new VirtualDevice; + + if ( ( pVirtDev->GetMapMode().GetMapUnit() != rMapMode.GetMapUnit() ) || + ( pVirtDev->GetMapMode().GetScaleX() != rMapMode.GetScaleX() ) || + ( pVirtDev->GetMapMode().GetScaleY() != rMapMode.GetScaleY() ) ) + { + MapMode aMapMode( rMapMode ); + aMapMode.SetOrigin( Point( 0, 0 ) ); + pVirtDev->SetMapMode( aMapMode ); + } + + return pVirtDev; +} + +inline void ImpEditEngine::EraseVirtualDevice() +{ + delete pVirtDev; + pVirtDev = 0; +} + +#ifndef SVX_LIGHT +inline EditUndoManager& ImpEditEngine::GetUndoManager() +{ + if ( !pUndoManager ) + pUndoManager = new EditUndoManager( this ); + return *pUndoManager; +} +#endif + +inline ParaPortion* ImpEditEngine::FindParaPortion( ContentNode* pNode ) const +{ + sal_uInt16 nPos = aEditDoc.GetPos( pNode ); + DBG_ASSERT( nPos < GetParaPortions().Count(), "Portionloser Node?" ); + return GetParaPortions()[ nPos ]; +} + +inline void ImpEditEngine::GetCharStretching( sal_uInt16& rX, sal_uInt16& rY ) +{ + rX = nStretchX; + rY = nStretchY; +} + +inline short ImpEditEngine::GetXValue( short nXValue ) const +{ + if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) + return nXValue; + + return (short) ((long)nXValue*nStretchX/100); +} + +inline sal_uInt16 ImpEditEngine::GetXValue( sal_uInt16 nXValue ) const +{ + if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) + return nXValue; + + return (sal_uInt16) ((long)nXValue*nStretchX/100); +} + +inline long ImpEditEngine::GetXValue( long nXValue ) const +{ + if ( !aStatus.DoStretch() || ( nStretchX == 100 ) ) + return nXValue; + + return nXValue*nStretchX/100; +} + +inline short ImpEditEngine::GetYValue( short nYValue ) const +{ + if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) + return nYValue; + + return (short) ((long)nYValue*nStretchY/100); +} + +inline sal_uInt16 ImpEditEngine::GetYValue( sal_uInt16 nYValue ) const +{ + if ( !aStatus.DoStretch() || ( nStretchY == 100 ) ) + return nYValue; + + return (sal_uInt16) ((long)nYValue*nStretchY/100); +} + +inline void ImpEditView::SetPointer( const Pointer& rPointer ) +{ + delete pPointer; + pPointer = new Pointer( rPointer ); +} + +inline const Pointer& ImpEditView::GetPointer() +{ + if ( !pPointer ) + { + pPointer = new Pointer( IsVertical() ? POINTER_TEXT_VERTICAL : POINTER_TEXT ); + return *pPointer; + } + + if(POINTER_TEXT == pPointer->GetStyle() && IsVertical()) + { + delete pPointer; + pPointer = new Pointer(POINTER_TEXT_VERTICAL); + } + else if(POINTER_TEXT_VERTICAL == pPointer->GetStyle() && !IsVertical()) + { + delete pPointer; + pPointer = new Pointer(POINTER_TEXT); + } + + return *pPointer; +} + +inline void ImpEditView::SetCursor( const Cursor& rCursor ) +{ + delete pCursor; + pCursor = new Cursor( rCursor ); +} + +inline Cursor* ImpEditView::GetCursor() +{ + if ( !pCursor ) + pCursor = new Cursor; + return pCursor; +} + +void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit ); +BYTE GetCharTypeForCompression( xub_Unicode cChar ); +Point Rotate( const Point& rPoint, short nOrientation, const Point& rOrigin ); + +}//end of namespace binfilter +#endif // _IMPEDIT_HXX + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/makefile.mk b/binfilter/bf_svx/source/editeng/makefile.mk new file mode 100644 index 000000000000..77799043089e --- /dev/null +++ b/binfilter/bf_svx/source/editeng/makefile.mk @@ -0,0 +1,85 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +EXTERNAL_WARNINGS_NOT_ERRORS := TRUE + +PRJ=..$/..$/.. +BFPRJ=..$/.. + +PRJNAME=binfilter +TARGET=svx_editeng + +NO_HIDS=TRUE + +PROJECTPCH4DLL=TRUE +PROJECTPCH=eeng_pch +PROJECTPCHSOURCE=svx_eeng_pch + +ENABLE_EXCEPTIONS=TRUE + + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(BFPRJ)$/util$/makefile.pmk +INC+= -I$(PRJ)$/inc$/bf_svx + +# --- Allgemein ---------------------------------------------------------- + +.IF "$(editdebug)" != "" || "$(EDITDEBUG)" != "" +CDEFS+=-DEDITDEBUG +.ENDIF + +SLOFILES = \ + $(SLO)$/svx_txtrange.obj \ + $(SLO)$/svx_forbiddencharacterstable.obj \ + $(SLO)$/svx_swafopt.obj \ + $(SLO)$/svx_editattr.obj \ + $(SLO)$/svx_editdbg.obj \ + $(SLO)$/svx_editdoc.obj \ + $(SLO)$/svx_editdoc2.obj \ + $(SLO)$/svx_editeng.obj \ + $(SLO)$/svx_editobj.obj \ + $(SLO)$/svx_editsel.obj \ + $(SLO)$/svx_editundo.obj \ + $(SLO)$/svx_editview.obj \ + $(SLO)$/svx_eerdll.obj \ + $(SLO)$/svx_impedit.obj \ + $(SLO)$/svx_impedit2.obj \ + $(SLO)$/svx_impedit3.obj \ + $(SLO)$/svx_impedit4.obj \ + $(SLO)$/svx_impedit5.obj \ + $(SLO)$/svx_unolingu.obj + +SRS1NAME=$(TARGET) +SRC1FILES= svx_editeng.src + +EXCEPTIONSFILES= \ + $(SLO)$/svx_unolingu.obj + +.INCLUDE : target.mk + diff --git a/binfilter/bf_svx/source/editeng/svx_editattr.cxx b/binfilter/bf_svx/source/editeng/svx_editattr.cxx new file mode 100644 index 000000000000..b8be0ec71f1f --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editattr.cxx @@ -0,0 +1,452 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitem.hxx" +#include "eeitemid.hxx" + +#include <svxfont.hxx> + + +#include <bf_svtools/poolitem.hxx> + +#include "itemdata.hxx" + +#include <tools/date.hxx> + +#include <tools/time.hxx> + +#include <fontitem.hxx> +#include <postitem.hxx> +#include <wghtitem.hxx> +#include <udlnitem.hxx> +#include <cntritem.hxx> +#include <shdditem.hxx> +#include <escpitem.hxx> +#include <wrlmitem.hxx> +#include <fhgtitem.hxx> +#include <crsditem.hxx> +#include <cscoitem.hxx> +#include <kernitem.hxx> +#include <akrnitem.hxx> +#include <langitem.hxx> +#include <emphitem.hxx> +#include <charscaleitem.hxx> +#include <charreliefitem.hxx> +#include <editattr.hxx> + +#include <vcl/outdev.hxx> + +namespace binfilter { + +/*N*/ DBG_NAME( EE_EditAttrib ) + +// ------------------------------------------------------------------------- +// class EditAttrib +// ------------------------------------------------------------------------- +/*N*/ EditAttrib::EditAttrib( const SfxPoolItem& rAttr ) +/*N*/ { +/*N*/ DBG_CTOR( EE_EditAttrib, 0 ); +/*N*/ pItem = &rAttr; +/*N*/ } + +/*N*/ EditAttrib::~EditAttrib() +/*N*/ { +/*N*/ DBG_DTOR( EE_EditAttrib, 0 ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttrib +// ------------------------------------------------------------------------- +/*N*/ EditCharAttrib::EditCharAttrib( const SfxPoolItem& rAttr, USHORT nS, USHORT nE ) +/*N*/ : EditAttrib( rAttr ) +/*N*/ { +/*N*/ nStart = nS; +/*N*/ nEnd = nE; +/*N*/ bFeature = FALSE; +/*N*/ bEdge = FALSE; +/*N*/ +/*N*/ DBG_ASSERT( ( rAttr.Which() >= EE_ITEMS_START ) && ( rAttr.Which() <= EE_ITEMS_END ), "EditCharAttrib CTOR: Invalid id!" ); +/*N*/ DBG_ASSERT( ( rAttr.Which() < EE_FEATURE_START ) || ( rAttr.Which() > EE_FEATURE_END ) || ( nE = (nS+1) ), "EditCharAttrib CTOR: Invalid feature!" ); +/*N*/ } + +/*N*/ void EditCharAttrib::SetFont( SvxFont&, OutputDevice* ) +/*N*/ { +/*N*/ } + + +// ------------------------------------------------------------------------- +// class EditCharAttribFont +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribFont::EditCharAttribFont( const SvxFontItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_FONTINFO || rAttr.Which() == EE_CHAR_FONTINFO_CJK || rAttr.Which() == EE_CHAR_FONTINFO_CTL, "Kein Fontattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribFont::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ const SvxFontItem& rAttr = (const SvxFontItem&)(*GetItem()); +/*N*/ +/*N*/ rFont.SetName( rAttr.GetFamilyName() ); +/*N*/ rFont.SetFamily( rAttr.GetFamily() ); +/*N*/ rFont.SetPitch( rAttr.GetPitch() ); +/*N*/ rFont.SetCharSet( rAttr.GetCharSet() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribItalic +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribItalic::EditCharAttribItalic( const SvxPostureItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_ITALIC || rAttr.Which() == EE_CHAR_ITALIC_CJK || rAttr.Which() == EE_CHAR_ITALIC_CTL, "Kein Italicattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribItalic::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetItalic( ((const SvxPostureItem*)GetItem())->GetPosture() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribWeight +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribWeight::EditCharAttribWeight( const SvxWeightItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_WEIGHT || rAttr.Which() == EE_CHAR_WEIGHT_CJK || rAttr.Which() == EE_CHAR_WEIGHT_CTL, "Kein Weightttribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribWeight::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetWeight( (FontWeight)((const SvxWeightItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribUnderline +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribUnderline::EditCharAttribUnderline( const SvxUnderlineItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_UNDERLINE, "Kein Underlineattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribUnderline::SetFont( SvxFont& rFont, OutputDevice* pOutDev ) +/*N*/ { +/*N*/ rFont.SetUnderline( (FontUnderline)((const SvxUnderlineItem*)GetItem())->GetValue() ); +/*N*/ if ( pOutDev ) +/*?*/ pOutDev->SetTextLineColor( ((const SvxUnderlineItem*)GetItem())->GetColor() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribFontHeight +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribFontHeight::EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_FONTHEIGHT || rAttr.Which() == EE_CHAR_FONTHEIGHT_CJK || rAttr.Which() == EE_CHAR_FONTHEIGHT_CTL, "Kein Heightattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribFontHeight::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ // Prop wird ignoriert +/*N*/ rFont.SetSize( Size( rFont.GetSize().Width(), ((const SvxFontHeightItem*)GetItem())->GetHeight() ) ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribFontWidth +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribFontWidth::EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_FONTWIDTH, "Kein Widthattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribFontWidth::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ // must be calculated outside, because f(device)... +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribStrikeout +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribStrikeout::EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_STRIKEOUT, "Kein Sizeattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribStrikeout::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetStrikeout( (FontStrikeout)((const SvxCrossedOutItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribColor +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribColor::EditCharAttribColor( const SvxColorItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_COLOR, "Kein Colorattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetColor( ((const SvxColorItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribLanguage +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribLanguage::EditCharAttribLanguage( const SvxLanguageItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( ( rAttr.Which() == EE_CHAR_LANGUAGE ) || ( rAttr.Which() == EE_CHAR_LANGUAGE_CJK ) || ( rAttr.Which() == EE_CHAR_LANGUAGE_CTL ), "Kein Languageattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribLanguage::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetLanguage( ((const SvxLanguageItem*)GetItem())->GetLanguage() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribShadow +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribShadow::EditCharAttribShadow( const SvxShadowedItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_SHADOW, "Kein Shadowattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribShadow::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetShadow( (BOOL)((const SvxShadowedItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribEscapement +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribEscapement::EditCharAttribEscapement( const SvxEscapementItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_ESCAPEMENT, "Kein Escapementattribut!" ); +/*N*/ } + +#if defined( WIN ) && !defined( WNT ) +#pragma optimize ("", off) +#endif + +/*N*/ void EditCharAttribEscapement::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ USHORT nProp = ((const SvxEscapementItem*)GetItem())->GetProp(); +/*N*/ rFont.SetPropr( (BYTE)nProp ); +/*N*/ +/*N*/ short nEsc = ((const SvxEscapementItem*)GetItem())->GetEsc(); +/*N*/ if ( nEsc == DFLT_ESC_AUTO_SUPER ) +/*N*/ nEsc = 100 - nProp; +/*N*/ else if ( nEsc == DFLT_ESC_AUTO_SUB ) +/*N*/ nEsc = -( 100 - nProp ); +/*N*/ rFont.SetEscapement( nEsc ); +/*N*/ } + +#if defined( WIN ) && !defined( WNT ) +#pragma optimize ("", on) +#endif + + +// ------------------------------------------------------------------------- +// class EditCharAttribOutline +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribOutline::EditCharAttribOutline( const SvxContourItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_OUTLINE, "Kein Outlineattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribOutline::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetOutline( (BOOL)((const SvxContourItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribTab +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribTab::EditCharAttribTab( const SfxVoidItem& rAttr, USHORT nPos ) +/*N*/ : EditCharAttrib( rAttr, nPos, nPos+1 ) +/*N*/ { +/*N*/ SetFeature( TRUE ); +/*N*/ } + +/*N*/ void EditCharAttribTab::SetFont( SvxFont&, OutputDevice* ) +/*N*/ { +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribLineBreak +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribLineBreak::EditCharAttribLineBreak( const SfxVoidItem& rAttr, USHORT nPos ) +/*N*/ : EditCharAttrib( rAttr, nPos, nPos+1 ) +/*N*/ { +/*N*/ SetFeature( TRUE ); +/*N*/ } + +/*N*/ void EditCharAttribLineBreak::SetFont( SvxFont&, OutputDevice* ) +/*N*/ { +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribField +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribField::EditCharAttribField( const SvxFieldItem& rAttr, USHORT nPos ) +/*N*/ : EditCharAttrib( (const SfxPoolItem&)rAttr, nPos, nPos+1 ) +/*N*/ { +/*N*/ SetFeature( TRUE ); // !!! +/*N*/ pTxtColor = 0; +/*N*/ pFldColor = 0; +/*N*/ } + +/*N*/ void EditCharAttribField::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ if ( pFldColor ) +/*N*/ { +/*N*/ rFont.SetFillColor( *pFldColor ); +/*N*/ rFont.SetTransparent( FALSE ); +/*N*/ } +/*N*/ if ( pTxtColor ) +/*N*/ rFont.SetColor( *pTxtColor ); +/*N*/ } + +/*N*/ EditCharAttribField::EditCharAttribField( const EditCharAttribField& rAttr ) +/*N*/ : EditCharAttrib( *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd() ), +/*N*/ aFieldValue( rAttr.aFieldValue ) +/*N*/ { +/*N*/ // Diesen CCTOR nur fuer temporaeres Object verwenden, +/*N*/ // Item wird nicht gepoolt. +/*N*/ pTxtColor = rAttr.pTxtColor ? new Color( *rAttr.pTxtColor ) : 0; +/*N*/ pFldColor = rAttr.pFldColor ? new Color( *rAttr.pFldColor ) : 0; +/*N*/ } + +/*N*/ EditCharAttribField::~EditCharAttribField() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +/*N*/ BOOL EditCharAttribField::operator == ( const EditCharAttribField& rAttr ) const +/*N*/ { +/*N*/ if ( aFieldValue != rAttr.aFieldValue ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( ( pTxtColor && !rAttr.pTxtColor ) || ( !pTxtColor && rAttr.pTxtColor ) ) +/*N*/ return FALSE; +/*N*/ if ( ( pTxtColor && rAttr.pTxtColor ) && ( *pTxtColor != *rAttr.pTxtColor ) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( ( pFldColor && !rAttr.pFldColor ) || ( !pFldColor && rAttr.pFldColor ) ) +/*N*/ return FALSE; +/*N*/ if ( ( pFldColor && rAttr.pFldColor ) && ( *pFldColor != *rAttr.pFldColor ) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribPairKerning +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribPairKerning::EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_PAIRKERNING, "Kein PairKerning!" ); +/*N*/ } + +/*N*/ void EditCharAttribPairKerning::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetKerning( ((const SvxAutoKernItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribKerning +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribKerning::EditCharAttribKerning( const SvxKerningItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_KERNING, "Kein Kerning!" ); +/*N*/ } + +/*N*/ void EditCharAttribKerning::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetFixKerning( ((const SvxKerningItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribWordLineMode +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribWordLineMode::EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_WLM, "Kein Kerning!" ); +/*N*/ } + +/*N*/ void EditCharAttribWordLineMode::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetWordLineMode( ((const SvxWordLineModeItem*)GetItem())->GetValue() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribEmphasisMark +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribEmphasisMark::EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_EMPHASISMARK, "Kein Emphasisattribut!" ); +/*N*/ } + +/*N*/ void EditCharAttribEmphasisMark::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetEmphasisMark( ((const SvxEmphasisMarkItem*)GetItem())->GetEmphasisMark() ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditCharAttribRelief +// ------------------------------------------------------------------------- +/*N*/ EditCharAttribRelief::EditCharAttribRelief( const SvxCharReliefItem& rAttr, USHORT nStart, USHORT nEnd ) +/*N*/ : EditCharAttrib( rAttr, nStart, nEnd ) +/*N*/ { +/*N*/ DBG_ASSERT( rAttr.Which() == EE_CHAR_RELIEF, "Not a relief attribute!" ); +/*N*/ } + +/*N*/ void EditCharAttribRelief::SetFont( SvxFont& rFont, OutputDevice* ) +/*N*/ { +/*N*/ rFont.SetRelief( (FontRelief)((const SvxCharReliefItem*)GetItem())->GetValue() ); +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editdbg.cxx b/binfilter/bf_svx/source/editeng/svx_editdbg.cxx new file mode 100644 index 000000000000..2e319fe2eb68 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editdbg.cxx @@ -0,0 +1,75 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitem.hxx" +#include "eeitemid.hxx" + + + + + +#include <vcl/window.hxx> + +#include <editdoc.hxx> +namespace binfilter { + +#if defined( DBG_UTIL ) || ( OSL_DEBUG_LEVEL > 1 ) + + + + + + + + + +/*N*/ BOOL CheckOrderedList( CharAttribArray& rAttribs, BOOL bStart ) +/*N*/ { +/*N*/ USHORT nPrev = 0; +/*N*/ for ( USHORT nAttr = 0; nAttr < rAttribs.Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttribs[nAttr]; +/*N*/ USHORT nCur = bStart ? pAttr->GetStart() : pAttr->GetEnd(); +/*N*/ if ( nCur < nPrev ) +/*N*/ return FALSE; +/*N*/ +/*N*/ nPrev = nCur; +/*N*/ } +/*N*/ return TRUE; +/*N*/ } + +#endif + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editdoc.cxx b/binfilter/bf_svx/source/editeng/svx_editdoc.cxx new file mode 100644 index 000000000000..10ebae9f0bfb --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editdoc.cxx @@ -0,0 +1,1993 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitem.hxx" +#include "eeitemid.hxx" + +#include <tstpitem.hxx> +#include <fontitem.hxx> +#include <crsditem.hxx> +#include <fhgtitem.hxx> +#include <postitem.hxx> +#include <kernitem.hxx> +#include <wrlmitem.hxx> +#include <wghtitem.hxx> +#include <udlnitem.hxx> +#include <cntritem.hxx> +#include <escpitem.hxx> +#include <shdditem.hxx> +#include <akrnitem.hxx> +#include <cscoitem.hxx> +#include <langitem.hxx> +#include <emphitem.hxx> +#include <charreliefitem.hxx> + +#include <vcl/outdev.hxx> + +#include <editdoc.hxx> +#include <eerdll.hxx> +#include <eerdll2.hxx> + +#include <tools/stream.hxx> + +#include <tools/shl.hxx> + +#include <com/sun/star/i18n/ScriptType.hpp> + +#include <stdlib.h> // qsort +namespace binfilter { + +using namespace ::com::sun::star; + + +// ------------------------------------------------------------ + +/*N*/ USHORT GetScriptItemId( USHORT nItemId, short nScriptType ) +/*N*/ { +/*N*/ USHORT nId = nItemId; +/*N*/ +/*N*/ if ( ( nScriptType == i18n::ScriptType::ASIAN ) || +/*N*/ ( nScriptType == i18n::ScriptType::COMPLEX ) ) +/*N*/ { +/*N*/ switch ( nItemId ) +/*N*/ { +/*N*/ case EE_CHAR_LANGUAGE: +/*N*/ nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_LANGUAGE_CJK : EE_CHAR_LANGUAGE_CTL; +/*N*/ break; +/*N*/ case EE_CHAR_FONTINFO: +/*N*/ nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_FONTINFO_CJK : EE_CHAR_FONTINFO_CTL; +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT: +/*N*/ nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_FONTHEIGHT_CJK : EE_CHAR_FONTHEIGHT_CTL; +/*N*/ break; +/*N*/ case EE_CHAR_WEIGHT: +/*N*/ nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_WEIGHT_CJK : EE_CHAR_WEIGHT_CTL; +/*N*/ break; +/*N*/ case EE_CHAR_ITALIC: +/*N*/ nId = ( nScriptType == i18n::ScriptType::ASIAN ) ? EE_CHAR_ITALIC_CJK : EE_CHAR_ITALIC_CTL; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return nId; +/*N*/ } + +/*N*/ BOOL IsScriptItemValid( USHORT nItemId, short nScriptType ) +/*N*/ { +/*N*/ BOOL bValid = TRUE; +/*N*/ +/*N*/ switch ( nItemId ) +/*N*/ { +/*N*/ case EE_CHAR_LANGUAGE: +/*N*/ bValid = nScriptType == i18n::ScriptType::LATIN; +/*N*/ break; +/*N*/ case EE_CHAR_LANGUAGE_CJK: +/*N*/ bValid = nScriptType == i18n::ScriptType::ASIAN; +/*N*/ break; +/*N*/ case EE_CHAR_LANGUAGE_CTL: +/*N*/ bValid = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ break; +/*N*/ case EE_CHAR_FONTINFO: +/*N*/ bValid = nScriptType == i18n::ScriptType::LATIN; +/*N*/ break; +/*N*/ case EE_CHAR_FONTINFO_CJK: +/*N*/ bValid = nScriptType == i18n::ScriptType::ASIAN; +/*N*/ break; +/*N*/ case EE_CHAR_FONTINFO_CTL: +/*N*/ bValid = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT: +/*N*/ bValid = nScriptType == i18n::ScriptType::LATIN; +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT_CJK: +/*N*/ bValid = nScriptType == i18n::ScriptType::ASIAN; +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT_CTL: +/*N*/ bValid = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ break; +/*N*/ case EE_CHAR_WEIGHT: +/*N*/ bValid = nScriptType == i18n::ScriptType::LATIN; +/*N*/ break; +/*N*/ case EE_CHAR_WEIGHT_CJK: +/*N*/ bValid = nScriptType == i18n::ScriptType::ASIAN; +/*N*/ break; +/*N*/ case EE_CHAR_WEIGHT_CTL: +/*N*/ bValid = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ break; +/*N*/ case EE_CHAR_ITALIC: +/*N*/ bValid = nScriptType == i18n::ScriptType::LATIN; +/*N*/ break; +/*N*/ case EE_CHAR_ITALIC_CJK: +/*N*/ bValid = nScriptType == i18n::ScriptType::ASIAN; +/*N*/ break; +/*N*/ case EE_CHAR_ITALIC_CTL: +/*N*/ bValid = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ return bValid; +/*N*/ } + + +// ------------------------------------------------------------ + +// Sollte spaeter zentral nach TOOLS/STRING (Aktuell: 303) +// fuer Grep: WS_TARGET + +/*N*/ DBG_NAME( EE_TextPortion ) +/*N*/ DBG_NAME( EE_EditLine ) +/*N*/ DBG_NAME( EE_ContentNode ) +/*N*/ DBG_NAME( EE_CharAttribList ) + +/*N*/ SfxItemInfo aItemInfos[EDITITEMCOUNT] = { +/*N*/ { SID_ATTR_FRAMEDIRECTION, SFX_ITEM_POOLABLE }, // EE_PARA_WRITINGDIR +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_PARA_XMLATTRIBS +/*N*/ { SID_ATTR_PARA_HANGPUNCTUATION, SFX_ITEM_POOLABLE }, // EE_PARA_HANGINGPUNCTUATION +/*N*/ { SID_ATTR_PARA_FORBIDDEN_RULES, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_PARA_SCRIPTSPACE, SFX_ITEM_POOLABLE }, // EE_PARA_ASIANCJKSPACING +/*N*/ { SID_ATTR_NUMBERING_RULE, SFX_ITEM_POOLABLE }, // EE_PARA_NUMBULL +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_PARA_HYPHENATE +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_PARA_BULLETSTATE +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_PARA_OUTLLRSPACE +/*N*/ { SID_ATTR_PARA_OUTLLEVEL, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_PARA_BULLET, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_PARA_LINESPACE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_PARA_ADJUST, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_TABSTOP, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_COLOR, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_FONT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_FONTHEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_SCALEWIDTH, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_WEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_UNDERLINE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_STRIKEOUT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_POSTURE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CONTOUR, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_SHADOWED, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_ESCAPEMENT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_AUTOKERN, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_KERNING, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_WORDLINEMODE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_LANGUAGE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CJK_LANGUAGE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CTL_LANGUAGE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CJK_FONT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CTL_FONT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CJK_FONTHEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CTL_FONTHEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CJK_WEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CTL_WEIGHT, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CJK_POSTURE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_CTL_POSTURE, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_EMPHASISMARK, SFX_ITEM_POOLABLE }, +/*N*/ { SID_ATTR_CHAR_RELIEF, SFX_ITEM_POOLABLE }, +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_CHAR_RUBI_DUMMY +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_CHAR_XMLATTRIBS +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_FEATURE_TAB +/*N*/ { 0, SFX_ITEM_POOLABLE }, // EE_FEATURE_LINEBR +/*N*/ { SID_ATTR_CHAR_CHARSETCOLOR, SFX_ITEM_POOLABLE }, // EE_FEATURE_NOTCONV +/*N*/ { SID_FIELD, SFX_ITEM_POOLABLE } +/*N*/ }; + +/*N*/ USHORT aV1Map[] = { +/*N*/ 3999, 4001, 4002, 4003, 4004, 4005, 4006, +/*N*/ 4007, 4008, 4009, 4010, 4011, 4012, 4013, 4017, 4018, 4019 // MI: 4019? +/*N*/ }; + +/*N*/ USHORT aV2Map[] = { +/*N*/ 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, 4008, 4009, +/*N*/ 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4018, 4019, 4020 +/*N*/ }; + +/*N*/ USHORT aV3Map[] = { +/*N*/ 3997, 3998, 3999, 4000, 4001, 4002, 4003, 4004, 4005, 4006, 4007, +/*N*/ 4009, 4010, 4011, 4012, 4013, 4014, 4015, 4016, 4017, 4018, 4019, +/*N*/ 4020, 4021 +/*N*/ }; + +/*N*/ USHORT aV4Map[] = { +/*N*/ 3994, 3995, 3996, 3997, 3998, 3999, 4000, 4001, 4002, 4003, +/*N*/ 4004, 4005, 4006, 4007, 4008, 4009, 4010, 4011, 4012, 4013, +/*N*/ 4014, 4015, 4016, 4017, 4018, +/*N*/ /* CJK Items inserted here: EE_CHAR_LANGUAGE - EE_CHAR_XMLATTRIBS */ +/*N*/ 4034, 4035, 4036, 4037 +/*N*/ }; + +/*N*/ SV_IMPL_PTRARR( ContentList, ContentNode* ); +/*N*/ SV_IMPL_VARARR( ScriptTypePosInfos, ScriptTypePosInfo ); +/*N*/ SV_IMPL_VARARR( WritingDirectionInfos, WritingDirectionInfo ); +// SV_IMPL_VARARR( ExtraCharInfos, ExtraCharInfo ); + + +/*N*/ int SAL_CALL CompareStart( const void* pFirst, const void* pSecond ) +/*N*/ { +/*N*/ if ( (*((EditCharAttrib**)pFirst))->GetStart() < (*((EditCharAttrib**)pSecond))->GetStart() ) +/*N*/ return (-1); +/*N*/ else if ( (*((EditCharAttrib**)pFirst))->GetStart() > (*((EditCharAttrib**)pSecond))->GetStart() ) +/*N*/ return (1); +/*N*/ return 0; +/*N*/ } + +/*N*/ EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, USHORT nS, USHORT nE ) +/*N*/ { +/*N*/ // das neue Attribut im Pool anlegen +/*N*/ const SfxPoolItem& rNew = rPool.Put( rAttr ); +/*N*/ +/*N*/ EditCharAttrib* pNew = 0; +/*N*/ switch( rNew.Which() ) +/*N*/ { +/*N*/ case EE_CHAR_LANGUAGE: +/*N*/ case EE_CHAR_LANGUAGE_CJK: +/*N*/ case EE_CHAR_LANGUAGE_CTL: +/*N*/ { +/*N*/ pNew = new EditCharAttribLanguage( (const SvxLanguageItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_COLOR: +/*N*/ { +/*N*/ pNew = new EditCharAttribColor( (const SvxColorItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_FONTINFO: +/*N*/ case EE_CHAR_FONTINFO_CJK: +/*N*/ case EE_CHAR_FONTINFO_CTL: +/*N*/ { +/*N*/ pNew = new EditCharAttribFont( (const SvxFontItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT: +/*N*/ case EE_CHAR_FONTHEIGHT_CJK: +/*N*/ case EE_CHAR_FONTHEIGHT_CTL: +/*N*/ { +/*N*/ pNew = new EditCharAttribFontHeight( (const SvxFontHeightItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_FONTWIDTH: +/*N*/ { +/*N*/ pNew = new EditCharAttribFontWidth( (const SvxCharScaleWidthItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_WEIGHT: +/*N*/ case EE_CHAR_WEIGHT_CJK: +/*N*/ case EE_CHAR_WEIGHT_CTL: +/*N*/ { +/*N*/ pNew = new EditCharAttribWeight( (const SvxWeightItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_UNDERLINE: +/*N*/ { +/*N*/ pNew = new EditCharAttribUnderline( (const SvxUnderlineItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_EMPHASISMARK: +/*N*/ { +/*N*/ pNew = new EditCharAttribEmphasisMark( (const SvxEmphasisMarkItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_RELIEF: +/*N*/ { +/*N*/ pNew = new EditCharAttribRelief( (const SvxCharReliefItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_STRIKEOUT: +/*N*/ { +/*N*/ pNew = new EditCharAttribStrikeout( (const SvxCrossedOutItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_ITALIC: +/*N*/ case EE_CHAR_ITALIC_CJK: +/*N*/ case EE_CHAR_ITALIC_CTL: +/*N*/ { +/*N*/ pNew = new EditCharAttribItalic( (const SvxPostureItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_OUTLINE: +/*N*/ { +/*N*/ pNew = new EditCharAttribOutline( (const SvxContourItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_SHADOW: +/*N*/ { +/*N*/ pNew = new EditCharAttribShadow( (const SvxShadowedItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_ESCAPEMENT: +/*N*/ { +/*N*/ pNew = new EditCharAttribEscapement( (const SvxEscapementItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_PAIRKERNING: +/*N*/ { +/*N*/ pNew = new EditCharAttribPairKerning( (const SvxAutoKernItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_KERNING: +/*N*/ { +/*N*/ pNew = new EditCharAttribKerning( (const SvxKerningItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_WLM: +/*N*/ { +/*N*/ pNew = new EditCharAttribWordLineMode( (const SvxWordLineModeItem&)rNew, nS, nE ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_XMLATTRIBS: +/*N*/ { +/*?*/ pNew = new EditCharAttrib( rNew, nS, nE ); // Attrib is only for holding XML information... +/*N*/ } +/*N*/ break; +/*N*/ case EE_FEATURE_TAB: +/*N*/ { +/*N*/ pNew = new EditCharAttribTab( (const SfxVoidItem&)rNew, nS ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_FEATURE_LINEBR: +/*N*/ { +/*N*/ pNew = new EditCharAttribLineBreak( (const SfxVoidItem&)rNew, nS ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_FEATURE_FIELD: +/*N*/ { +/*N*/ pNew = new EditCharAttribField( (const SvxFieldItem&)rNew, nS ); +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ DBG_ERROR( "Ungueltiges Attribut!" ); +/*N*/ } +/*N*/ } +/*N*/ return pNew; +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditLine +// ------------------------------------------------------------------------- + +/*N*/ EditLine::EditLine() +/*N*/ { +/*N*/ DBG_CTOR( EE_EditLine, 0 ); +/*N*/ +/*N*/ nStart = nEnd = 0; +/*N*/ nStartPortion = 0; // damit in ungueltiger Zeile ohne Portions von einer gueltigen Zeile mit der Portion Nr0 unterscieden werden kann. +/*N*/ nEndPortion = 0; +/*N*/ nHeight = 0; +/*N*/ nStartPosX = 0; +/*N*/ nTxtHeight = 0; +/*N*/ nTxtWidth = 0; +/*N*/ nCrsrHeight = 0; +/*N*/ nMaxAscent = 0; +/*N*/ bHangingPunctuation = FALSE; +/*N*/ bInvalid = TRUE; +/*N*/ } + +/*N*/ EditLine::EditLine( const EditLine& r ) +/*N*/ { +/*N*/ DBG_CTOR( EE_EditLine, 0 ); +/*N*/ +/*N*/ nEnd = r.nEnd; +/*N*/ nStart = r.nStart; +/*N*/ nStartPortion = r.nStartPortion; +/*N*/ nEndPortion = r.nEndPortion; +/*N*/ bHangingPunctuation = r.bHangingPunctuation; +/*N*/ +/*N*/ nHeight = 0; +/*N*/ nStartPosX = 0; +/*N*/ nTxtHeight = 0; +/*N*/ nTxtWidth = 0; +/*N*/ nCrsrHeight = 0; +/*N*/ nMaxAscent = 0; +/*N*/ bInvalid = TRUE; +/*N*/ } + +/*N*/ EditLine::~EditLine() +/*N*/ { +/*N*/ DBG_DTOR( EE_EditLine, 0 ); +/*N*/ } + + +/*N*/ BOOL operator == ( const EditLine& r1, const EditLine& r2 ) +/*N*/ { +/*N*/ if ( r1.nStart != r2.nStart ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( r1.nEnd != r2.nEnd ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( r1.nStartPortion != r2.nStartPortion ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( r1.nEndPortion != r2.nEndPortion ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ EditLine& EditLine::operator = ( const EditLine& r ) +/*N*/ { +/*N*/ nEnd = r.nEnd; +/*N*/ nStart = r.nStart; +/*N*/ nEndPortion = r.nEndPortion; +/*N*/ nStartPortion = r.nStartPortion; +/*N*/ return *this; +/*N*/ } + + + +/*N*/ Size EditLine::CalcTextSize( ParaPortion& rParaPortion ) +/*N*/ { +/*N*/ Size aSz; +/*N*/ Size aTmpSz; +/*N*/ TextPortion* pPortion; +/*N*/ +/*N*/ USHORT nIndex = GetStart(); +/*N*/ +/*N*/ DBG_ASSERT( rParaPortion.GetTextPortions().Count(), "GetTextSize vor CreatePortions !" ); +/*N*/ +/*N*/ for ( USHORT n = nStartPortion; n <= nEndPortion; n++ ) +/*N*/ { +/*N*/ pPortion = rParaPortion.GetTextPortions().GetObject(n); +/*N*/ switch ( pPortion->GetKind() ) +/*N*/ { +/*N*/ case PORTIONKIND_TEXT: +/*N*/ case PORTIONKIND_FIELD: +/*N*/ case PORTIONKIND_HYPHENATOR: +/*N*/ { +/*N*/ aTmpSz = pPortion->GetSize(); +/*N*/ aSz.Width() += aTmpSz.Width(); +/*N*/ if ( aSz.Height() < aTmpSz.Height() ) +/*N*/ aSz.Height() = aTmpSz.Height(); +/*N*/ } +/*N*/ break; +/*N*/ case PORTIONKIND_TAB: +/*N*/ // case PORTIONKIND_EXTRASPACE: +/*N*/ { +/*N*/ aSz.Width() += pPortion->GetSize().Width(); +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ nIndex += pPortion->GetLen(); +/*N*/ } +/*N*/ +/*N*/ SetHeight( (USHORT)aSz.Height() ); +/*N*/ return aSz; +/*N*/ } + +// ------------------------------------------------------------------------- +// class EditLineList +// ------------------------------------------------------------------------- +/*N*/ EditLineList::EditLineList() +/*N*/ { +/*N*/ } + +/*N*/ EditLineList::~EditLineList() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +/*N*/ void EditLineList::Reset() +/*N*/ { +/*N*/ for ( USHORT nLine = 0; nLine < Count(); nLine++ ) +/*N*/ delete GetObject(nLine); +/*N*/ Remove( 0, Count() ); +/*N*/ } + +/*N*/ void EditLineList::DeleteFromLine( USHORT nDelFrom ) +/*N*/ { +/*N*/ DBG_ASSERT( nDelFrom <= (Count() - 1), "DeleteFromLine: Out of range" ); +/*N*/ for ( USHORT nL = nDelFrom; nL < Count(); nL++ ) +/*N*/ delete GetObject(nL); +/*N*/ Remove( nDelFrom, Count()-nDelFrom ); +/*N*/ } + + +// ------------------------------------------------------------------------- +// class EditSelection +// ------------------------------------------------------------------------- + +/*N*/ EditSelection::EditSelection() +/*N*/ { +/*N*/ } + +/*N*/ EditSelection::EditSelection( const EditPaM& rStartAndAnd ) +/*N*/ { +/*N*/ // koennte noch optimiert werden! +/*N*/ // nicht erst Def-CTOR vom PaM rufen! +/*N*/ aStartPaM = rStartAndAnd; +/*N*/ aEndPaM = rStartAndAnd; +/*N*/ } + +/*N*/ EditSelection::EditSelection( const EditPaM& rStart, const EditPaM& rEnd ) +/*N*/ { +/*N*/ // koennte noch optimiert werden! +/*N*/ aStartPaM = rStart; +/*N*/ aEndPaM = rEnd; +/*N*/ } + +/*N*/ EditSelection& EditSelection::operator = ( const EditPaM& rPaM ) +/*N*/ { +/*N*/ aStartPaM = rPaM; +/*N*/ aEndPaM = rPaM; +/*N*/ return *this; +/*N*/ } + +/*N*/ BOOL EditSelection::Adjust( const ContentList& rNodes ) +/*N*/ { +/*N*/ DBG_ASSERT( aStartPaM.GetIndex() <= aStartPaM.GetNode()->Len(), "Index im Wald in Adjust(1)" ); +/*N*/ DBG_ASSERT( aEndPaM.GetIndex() <= aEndPaM.GetNode()->Len(), "Index im Wald in Adjust(2)" ); +/*N*/ +/*N*/ ContentNode* pStartNode = aStartPaM.GetNode(); +/*N*/ ContentNode* pEndNode = aEndPaM.GetNode(); +/*N*/ +/*N*/ USHORT nStartNode = rNodes.GetPos( pStartNode ); +/*N*/ USHORT nEndNode = rNodes.GetPos( pEndNode ); +/*N*/ +/*N*/ DBG_ASSERT( nStartNode != USHRT_MAX, "Node im Wald in Adjust(1)" ); +/*N*/ DBG_ASSERT( nEndNode != USHRT_MAX, "Node im Wald in Adjust(2)" ); +/*N*/ +/*N*/ BOOL bSwap = FALSE; +/*N*/ if ( nStartNode > nEndNode ) +/*N*/ bSwap = TRUE; +/*N*/ else if ( ( nStartNode == nEndNode ) && ( aStartPaM.GetIndex() > aEndPaM.GetIndex() ) ) +/*N*/ bSwap = TRUE; +/*N*/ +/*N*/ if ( bSwap ) +/*N*/ { +/*?*/ EditPaM aTmpPaM( aStartPaM ); +/*?*/ aStartPaM = aEndPaM; +/*?*/ aEndPaM = aTmpPaM; +/*N*/ } +/*N*/ +/*N*/ return bSwap; +/*N*/ } + + +// ------------------------------------------------------------------------- +// class EditPaM +// ------------------------------------------------------------------------- +/*N*/ BOOL operator == ( const EditPaM& r1, const EditPaM& r2 ) +/*N*/ { +/*N*/ if ( r1.GetNode() != r2.GetNode() ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( r1.GetIndex() != r2.GetIndex() ) +/*N*/ return FALSE; +/*N*/ +/*N*/ return TRUE; +/*N*/ } + +/*N*/ EditPaM& EditPaM::operator = ( const EditPaM& rPaM ) +/*N*/ { +/*N*/ nIndex = rPaM.nIndex; +/*N*/ pNode = rPaM.pNode; +/*N*/ return *this; +/*N*/ } + +/*N*/ BOOL operator != ( const EditPaM& r1, const EditPaM& r2 ) +/*N*/ { +/*N*/ return !( r1 == r2 ); +/*N*/ } + + +// ------------------------------------------------------------------------- +// class ContentNode +// ------------------------------------------------------------------------- +/*N*/ ContentNode::ContentNode( SfxItemPool& rPool ) : aContentAttribs( rPool ) +/*N*/ { +/*N*/ DBG_CTOR( EE_ContentNode, 0 ); +/*N*/ } + +/*N*/ ContentNode::ContentNode( const XubString& rStr, const ContentAttribs& rContentAttribs ) : +/*N*/ XubString( rStr ), aContentAttribs( rContentAttribs ) +/*N*/ { +/*N*/ DBG_CTOR( EE_ContentNode, 0 ); +/*N*/ } + +/*N*/ ContentNode::~ContentNode() +/*N*/ { +/*N*/ DBG_DTOR( EE_ContentNode, 0 ); +/*N*/ } + +/*N*/ void ContentNode::ExpandAttribs( USHORT nIndex, USHORT nNew, SfxItemPool& rItemPool ) +/*N*/ { +/*N*/ if ( !nNew ) +/*N*/ return; +/*N*/ +/*N*/ // Da Features anders behandelt werden als normale Zeichenattribute, +/*N*/ // kann sich hier auch die Sortierung der Start-Liste aendern! +/*N*/ // In jedem if..., in dem weiter (n) Moeglichkeiten aufgrund von +/*N*/ // bFeature oder Spezialfall existieren, +/*N*/ // muessen (n-1) Moeglichkeiten mit bResort versehen werden. +/*N*/ // Die wahrscheinlichste Moeglichkeit erhaelt kein bResort, +/*N*/ // so dass nicht neu sortiert wird, wenn sich alle Attribute +/*N*/ // gleich verhalten. +/*N*/ BOOL bResort = FALSE; +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); +/*N*/ while ( pAttrib ) +/*N*/ { +/*N*/ if ( pAttrib->GetEnd() >= nIndex ) +/*N*/ { +/*N*/ // Alle Attribute hinter der Einfuegeposition verschieben... +/*N*/ if ( pAttrib->GetStart() > nIndex ) +/*N*/ { +/*N*/ pAttrib->MoveForward( nNew ); +/*N*/ } +/*N*/ // 0: Leeres Attribut expandieren, wenn an Einfuegestelle +/*N*/ else if ( pAttrib->IsEmpty() ) +/*N*/ { +/*?*/ // Index nicht pruefen, leeres durfte nur dort liegen. +/*?*/ // Wenn spaeter doch Ueberpruefung: +/*?*/ // Spezialfall: Start == 0; AbsLen == 1, nNew = 1 => Expand, weil durch Absatzumbruch! +/*?*/ // Start <= nIndex, End >= nIndex => Start=End=nIndex! +/*?*/ // if ( pAttrib->GetStart() == nIndex ) +/*?*/ pAttrib->Expand( nNew ); +/*N*/ } +/*N*/ // 1: Attribut startet davor, geht bis Index... +/*N*/ else if ( pAttrib->GetEnd() == nIndex ) // Start muss davor liegen +/*N*/ { +/*N*/ // Nur expandieren, wenn kein Feature, +/*N*/ // und wenn nicht in ExcludeListe! +/*N*/ // Sonst geht z.B. ein UL bis zum neuen ULDB, beide expandieren +/*N*/ // if ( !pAttrib->IsFeature() && !rExclList.FindAttrib( pAttrib->Which() ) ) +/*N*/ if ( !pAttrib->IsFeature() && !aCharAttribList.FindEmptyAttrib( pAttrib->Which(), nIndex ) ) +/*N*/ { +/*?*/ if ( !pAttrib->IsEdge() ) +/*?*/ pAttrib->Expand( nNew ); +/*N*/ } +/*N*/ else +/*N*/ bResort = TRUE; +/*N*/ } +/*N*/ // 2: Attribut startet davor, geht hinter Index... +/*N*/ else if ( ( pAttrib->GetStart() < nIndex ) && ( pAttrib->GetEnd() > nIndex ) ) +/*N*/ { +/*?*/ DBG_ASSERT( !pAttrib->IsFeature(), "Grosses Feature?!" ); +/*?*/ pAttrib->Expand( nNew ); +/*N*/ } +/*N*/ // 3: Attribut startet auf Index... +/*N*/ else if ( pAttrib->GetStart() == nIndex ) +/*N*/ { +/*?*/ if ( pAttrib->IsFeature() ) +/*?*/ { +/*?*/ pAttrib->MoveForward( nNew ); +/*?*/ bResort = TRUE; +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ if ( nIndex == 0 ) +/*?*/ { +/*?*/ pAttrib->Expand( nNew ); +/*?*/ bResort = TRUE; +/*?*/ } +/*?*/ else +/*?*/ pAttrib->MoveForward( nNew ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pAttrib->IsEdge() ) +/*?*/ pAttrib->SetEdge( FALSE ); +/*N*/ +/*N*/ DBG_ASSERT( !pAttrib->IsFeature() || ( pAttrib->GetLen() == 1 ), "Expand: FeaturesLen != 1" ); +/*N*/ +/*N*/ DBG_ASSERT( pAttrib->GetStart() <= pAttrib->GetEnd(), "Expand: Attribut verdreht!" ); +/*N*/ DBG_ASSERT( ( pAttrib->GetEnd() <= Len() ), "Expand: Attrib groesser als Absatz!" ); +/*N*/ if ( pAttrib->IsEmpty() ) +/*N*/ { +/*?*/ DBG_ERROR( "Leeres Attribut nach ExpandAttribs?" ); +/*?*/ bResort = TRUE; +/*?*/ aCharAttribList.GetAttribs().Remove( nAttr ); +/*?*/ rItemPool.Remove( *pAttrib->GetItem() ); +/*?*/ delete pAttrib; +/*?*/ nAttr--; +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); +/*N*/ } +/*N*/ +/*N*/ if ( bResort ) +/*N*/ aCharAttribList.ResortAttribs(); +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( CheckOrderedList( aCharAttribList.GetAttribs(), TRUE ), "Expand: Start-Liste verdreht" ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ContentNode::CollapsAttribs( USHORT nIndex, USHORT nDeleted, SfxItemPool& rItemPool ) +/*N*/ { +/*N*/ if ( !nDeleted ) +/*N*/ return; +/*N*/ +/*N*/ // Da Features anders behandelt werden als normale Zeichenattribute, +/*N*/ // kann sich hier auch die Sortierung der Start-Liste aendern! +/*N*/ BOOL bResort = FALSE; +/*N*/ BOOL bDelAttr = FALSE; +/*N*/ USHORT nEndChanges = nIndex+nDeleted; +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); +/*N*/ while ( pAttrib ) +/*N*/ { +/*N*/ bDelAttr = FALSE; +/*N*/ if ( pAttrib->GetEnd() >= nIndex ) +/*N*/ { +/*N*/ // Alles Attribute hinter der Einfuegeposition verschieben... +/*N*/ if ( pAttrib->GetStart() >= nEndChanges ) +/*N*/ { +/*N*/ pAttrib->MoveBackward( nDeleted ); +/*N*/ } +/*N*/ // 1. Innenliegende Attribute loeschen... +/*N*/ else if ( ( pAttrib->GetStart() >= nIndex ) && ( pAttrib->GetEnd() <= nEndChanges ) ) +/*N*/ { +/*N*/ // Spezialfall: Attrubt deckt genau den Bereich ab +/*N*/ // => als leeres Attribut behalten. +/*N*/ if ( !pAttrib->IsFeature() && ( pAttrib->GetStart() == nIndex ) && ( pAttrib->GetEnd() == nEndChanges ) ) +/*?*/ pAttrib->GetEnd() = nIndex; // leer +/*N*/ else +/*N*/ bDelAttr = TRUE; +/*N*/ } +/*N*/ // 2. Attribut beginnt davor, endet drinnen oder dahinter... +/*N*/ else if ( ( pAttrib->GetStart() <= nIndex ) && ( pAttrib->GetEnd() > nIndex ) ) +/*N*/ { +/*?*/ DBG_ASSERT( !pAttrib->IsFeature(), "Collapsing Feature!" ); +/*?*/ if ( pAttrib->GetEnd() <= nEndChanges ) // endet drinnen +/*?*/ pAttrib->GetEnd() = nIndex; +/*?*/ else +/*?*/ pAttrib->Collaps( nDeleted ); // endet dahinter +/*N*/ } +/*N*/ // 3. Attribut beginnt drinnen, endet dahinter... +/*N*/ else if ( ( pAttrib->GetStart() >= nIndex ) && ( pAttrib->GetEnd() > nEndChanges ) ) +/*N*/ { +/*?*/ // Features duerfen nicht expandieren! +/*?*/ if ( pAttrib->IsFeature() ) +/*?*/ { +/*?*/ pAttrib->MoveBackward( nDeleted ); +/*?*/ bResort = TRUE; +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ pAttrib->GetStart() = nEndChanges; +/*?*/ pAttrib->MoveBackward( nDeleted ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT( !pAttrib->IsFeature() || ( pAttrib->GetLen() == 1 ), "Expand: FeaturesLen != 1" ); +/*N*/ +/*N*/ DBG_ASSERT( pAttrib->GetStart() <= pAttrib->GetEnd(), "Collaps: Attribut verdreht!" ); +/*N*/ DBG_ASSERT( ( pAttrib->GetEnd() <= Len()) || bDelAttr, "Collaps: Attrib groesser als Absatz!" ); +/*N*/ if ( bDelAttr /* || pAttrib->IsEmpty() */ ) +/*N*/ { +/*N*/ bResort = TRUE; +/*N*/ aCharAttribList.GetAttribs().Remove( nAttr ); +/*N*/ rItemPool.Remove( *pAttrib->GetItem() ); +/*N*/ delete pAttrib; +/*N*/ nAttr--; +/*N*/ } +/*N*/ else if ( pAttrib->IsEmpty() ) +/*?*/ aCharAttribList.HasEmptyAttribs() = TRUE; +/*N*/ +/*N*/ nAttr++; +/*N*/ pAttrib = GetAttrib( aCharAttribList.GetAttribs(), nAttr ); +/*N*/ } +/*N*/ +/*N*/ if ( bResort ) +/*N*/ aCharAttribList.ResortAttribs(); +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( CheckOrderedList( aCharAttribList.GetAttribs(), TRUE ), "Collaps: Start-Liste verdreht" ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ContentNode::CopyAndCutAttribs( ContentNode* pPrevNode, SfxItemPool& rPool, BOOL bKeepEndingAttribs ) +/*N*/ { +/*N*/ DBG_ASSERT( pPrevNode, "kopieren von Attributen auf einen NULL-Pointer ?" ); +/*N*/ +/*N*/ xub_StrLen nCut = pPrevNode->Len(); +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( pPrevNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttrib ) +/*N*/ { +/*N*/ if ( pAttrib->GetEnd() < nCut ) +/*N*/ { +/*N*/ // bleiben unveraendert.... +/*N*/ ; +/*N*/ } +/*N*/ else if ( pAttrib->GetEnd() == nCut ) +/*N*/ { +/*N*/ // muessen als leeres Attribut kopiert werden. +/*N*/ if ( bKeepEndingAttribs && !pAttrib->IsFeature() && !aCharAttribList.FindAttrib( pAttrib->GetItem()->Which(), 0 ) ) +/*N*/ { +/*?*/ EditCharAttrib* pNewAttrib = MakeCharAttrib( rPool, *(pAttrib->GetItem()), 0, 0 ); +/*?*/ DBG_ASSERT( pNewAttrib, "MakeCharAttrib fehlgeschlagen!" ); +/*?*/ aCharAttribList.InsertAttrib( pNewAttrib ); +/*N*/ } +/*N*/ } +/*N*/ else if ( pAttrib->IsInside( nCut ) || ( !nCut && !pAttrib->GetStart() && !pAttrib->IsFeature() ) ) +/*N*/ { +/*?*/ // Wenn ganz vorne gecuttet wird, muss das Attribut erhalten bleiben! +/*?*/ // muessen kopiert und geaendert werden +/*?*/ EditCharAttrib* pNewAttrib = MakeCharAttrib( rPool, *(pAttrib->GetItem()), 0, pAttrib->GetEnd()-nCut ); +/*?*/ DBG_ASSERT( pNewAttrib, "MakeCharAttrib fehlgeschlagen!" ); +/*?*/ aCharAttribList.InsertAttrib( pNewAttrib ); +/*?*/ // stutzen: +/*?*/ pAttrib->GetEnd() = nCut; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ // alle dahinter verschieben in den neuen Node (this) +/*?*/ // pPrevNode->GetCharAttribs().RemoveAttrib( pAttrib ); +/*?*/ pPrevNode->GetCharAttribs().GetAttribs().Remove( nAttr ); +/*?*/ aCharAttribList.InsertAttrib( pAttrib ); +/*?*/ DBG_ASSERT( pAttrib->GetStart() >= nCut, "Start < nCut!" ); +/*?*/ DBG_ASSERT( pAttrib->GetEnd() >= nCut, "End < nCut!" ); +/*?*/ pAttrib->GetStart() -= nCut; +/*?*/ pAttrib->GetEnd() -= nCut; +/*?*/ nAttr--; +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttrib = GetAttrib( pPrevNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ } + +/*N*/ void ContentNode::AppendAttribs( ContentNode* pNextNode ) +/*N*/ { +/*N*/ DBG_ASSERT( pNextNode, "kopieren von Attributen von einen NULL-Pointer ?" ); +/*N*/ +/*N*/ USHORT nNewStart = Len(); +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( aCharAttribList.DbgCheckAttribs(), "Attribute VOR AppendAttribs kaputt" ); +/*N*/ #endif +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( pNextNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttrib ) +/*N*/ { +/*?*/ // alle Attribute verschieben in den aktuellen Node (this) +/*?*/ BOOL bMelted = FALSE; +/*?*/ if ( ( pAttrib->GetStart() == 0 ) && ( !pAttrib->IsFeature() ) ) +/*?*/ { +/*?*/ // Evtl koennen Attribute zusammengefasst werden: +/*?*/ USHORT nTmpAttr = 0; +/*?*/ EditCharAttrib* pTmpAttrib = GetAttrib( aCharAttribList.GetAttribs(), nTmpAttr ); +/*?*/ while ( !bMelted && pTmpAttrib ) +/*?*/ { +/*?*/ if ( pTmpAttrib->GetEnd() == nNewStart ) +/*?*/ { +/*?*/ if ( ( pTmpAttrib->Which() == pAttrib->Which() ) && +/*?*/ ( *(pTmpAttrib->GetItem()) == *(pAttrib->GetItem() ) ) ) +/*?*/ { +/*?*/ pTmpAttrib->GetEnd() += pAttrib->GetLen(); +/*?*/ pNextNode->GetCharAttribs().GetAttribs().Remove( nAttr ); +/*?*/ // Vom Pool abmelden ?! +/*?*/ delete pAttrib; +/*?*/ bMelted = TRUE; +/*?*/ } +/*?*/ } +/*?*/ ++nTmpAttr; +/*?*/ pTmpAttrib = GetAttrib( aCharAttribList.GetAttribs(), nTmpAttr ); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if ( !bMelted ) +/*?*/ { +/*?*/ pAttrib->GetStart() += nNewStart; +/*?*/ pAttrib->GetEnd() += nNewStart; +/*?*/ aCharAttribList.InsertAttrib( pAttrib ); +/*?*/ ++nAttr; +/*?*/ } +/*?*/ pAttrib = GetAttrib( pNextNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ // Fuer die Attribute, die nur ruebergewandert sind: +/*N*/ pNextNode->GetCharAttribs().Clear(); +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( aCharAttribList.DbgCheckAttribs(), "Attribute NACH AppendAttribs kaputt" ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ContentNode::CreateDefFont() +/*N*/ { +/*N*/ // Erst alle Informationen aus dem Style verwenden... +/*N*/ SfxStyleSheet* pS = aContentAttribs.GetStyleSheet(); +/*N*/ if ( pS ) +/*N*/ CreateFont( GetCharAttribs().GetDefFont(), pS->GetItemSet() ); +/*N*/ +/*N*/ // ... dann die harte Absatzformatierung rueberbuegeln... +/*N*/ CreateFont( GetCharAttribs().GetDefFont(), +/*N*/ GetContentAttribs().GetItems(), ( pS ? FALSE : TRUE ) ); +/*N*/ } + +/*N*/ void ContentNode::SetStyleSheet( SfxStyleSheet* pS, BOOL bRecalcFont ) +/*N*/ { +/*N*/ aContentAttribs.SetStyleSheet( pS ); +/*N*/ if ( bRecalcFont ) +/*N*/ CreateDefFont(); +/*N*/ } + + +// ------------------------------------------------------------------------- +// class ContentAttribs +// ------------------------------------------------------------------------- +/*N*/ ContentAttribs::ContentAttribs( SfxItemPool& rPool ) : +/*N*/ aAttribSet( rPool, EE_PARA_START, EE_CHAR_END ) +/*N*/ { +/*N*/ pStyle = 0; +/*N*/ } + +/*N*/ ContentAttribs::ContentAttribs( const ContentAttribs& rRef ) : +/*N*/ aAttribSet( rRef.aAttribSet ) +/*N*/ { +/*N*/ pStyle = rRef.pStyle; +/*N*/ } + +/*N*/ ContentAttribs::~ContentAttribs() +/*N*/ { +/*N*/ } + +/*N*/ SvxTabStop ContentAttribs::FindTabStop( long nCurPos, USHORT nDefTab ) +/*N*/ { +/*N*/ const SvxTabStopItem& rTabs = (const SvxTabStopItem&) GetItem( EE_PARA_TABS ); +/*N*/ for ( USHORT i = 0; i < rTabs.Count(); i++ ) +/*N*/ { +/*N*/ const SvxTabStop& rTab = rTabs[i]; +/*N*/ if ( rTab.GetTabPos() > nCurPos ) +/*N*/ return rTab; +/*N*/ } +/*N*/ +/*N*/ // DefTab ermitteln... +/*N*/ SvxTabStop aTabStop; +/*N*/ long x = nCurPos / nDefTab + 1; +/*N*/ aTabStop.GetTabPos() = nDefTab * x; +/*N*/ return aTabStop; +/*N*/ } + +/*N*/ void ContentAttribs::SetStyleSheet( SfxStyleSheet* pS ) +/*N*/ { +/*N*/ BOOL bStyleChanged = ( pStyle != pS ); +/*N*/ pStyle = pS; +/*N*/ // #104799# Only when other style sheet, not when current style sheet modified +/*N*/ if ( pStyle && bStyleChanged ) +/*N*/ { +/*N*/ // Gezielt die Attribute aus der Absatzformatierung entfernen, die im Style +/*N*/ // spezifiziert sind, damit die Attribute des Styles wirken koennen. +/*N*/ const SfxItemSet& rStyleAttribs = pStyle->GetItemSet(); +/*N*/ for ( USHORT nWhich = EE_PARA_START; nWhich <= EE_CHAR_END; nWhich++ ) +/*N*/ { +/*N*/ // #99635# Don't change bullet on/off +/*N*/ if ( ( nWhich != EE_PARA_BULLETSTATE ) && ( rStyleAttribs.GetItemState( nWhich ) == SFX_ITEM_ON ) ) +/*N*/ aAttribSet.ClearItem( nWhich ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ const SfxPoolItem& ContentAttribs::GetItem( USHORT nWhich ) +/*N*/ { +/*N*/ // Harte Absatzattribute haben Vorrang! +/*N*/ SfxItemSet* pTakeFrom = &aAttribSet; +/*N*/ if ( pStyle && ( aAttribSet.GetItemState( nWhich, FALSE ) != SFX_ITEM_ON ) ) +/*N*/ pTakeFrom = &pStyle->GetItemSet(); +/*N*/ +/*N*/ return pTakeFrom->Get( nWhich ); +/*N*/ } + +/*N*/ BOOL ContentAttribs::HasItem( USHORT nWhich ) +/*N*/ { +/*N*/ BOOL bHasItem = FALSE; +/*N*/ if ( aAttribSet.GetItemState( nWhich, FALSE ) == SFX_ITEM_ON ) +/*N*/ bHasItem = TRUE; +/*N*/ else if ( pStyle && pStyle->GetItemSet().GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ bHasItem = TRUE; +/*N*/ +/*N*/ return bHasItem; +/*N*/ } + + + +// ---------------------------------------------------------------------- +// class ItemList +// ---------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +// class EditDoc +// ------------------------------------------------------------------------- +/*N*/ EditDoc::EditDoc( SfxItemPool* pPool ) +/*N*/ { +/*N*/ if ( pPool ) +/*N*/ { +/*N*/ pItemPool = pPool; +/*N*/ bOwnerOfPool = FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ pItemPool = new EditEngineItemPool( FALSE ); +/*?*/ bOwnerOfPool = TRUE; +/*N*/ } +/*N*/ +/*N*/ nDefTab = DEFTAB; +/*N*/ bIsVertical = FALSE; +/*N*/ +/*N*/ // Don't create a empty node, Clear() will be called in EditEngine-CTOR +/*N*/ +/*N*/ SetModified( FALSE ); +/*N*/ }; + +/*N*/ EditDoc::~EditDoc() +/*N*/ { +/*N*/ ImplDestroyContents(); +/*N*/ if ( bOwnerOfPool ) +/*?*/ delete pItemPool; +/*N*/ } + +/*N*/ void EditDoc::ImplDestroyContents() +/*N*/ { +/*N*/ for ( USHORT nNode = Count(); nNode; ) +/*N*/ RemoveItemsFromPool( GetObject( --nNode ) ); +/*N*/ DeleteAndDestroy( 0, Count() ); +/*N*/ } + +/*N*/ void EditDoc::RemoveItemsFromPool( ContentNode* pNode ) +/*N*/ { +/*N*/ for ( USHORT nAttr = 0; nAttr < pNode->GetCharAttribs().Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = pNode->GetCharAttribs().GetAttribs()[nAttr]; +/*N*/ GetItemPool().Remove( *pAttr->GetItem() ); +/*N*/ } +/*N*/ } + +/*N*/ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet, BOOL bSearchInParent, short nScriptType ) +/*N*/ { +/*N*/ Font aPrevFont( rFont ); +/*N*/ rFont.SetAlign( ALIGN_BASELINE ); +/*N*/ rFont.SetTransparent( TRUE ); +/*N*/ +/*N*/ USHORT nWhich_FontInfo = GetScriptItemId( EE_CHAR_FONTINFO, nScriptType ); +/*N*/ USHORT nWhich_Language = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ); +/*N*/ USHORT nWhich_FontHeight = GetScriptItemId( EE_CHAR_FONTHEIGHT, nScriptType ); +/*N*/ USHORT nWhich_Weight = GetScriptItemId( EE_CHAR_WEIGHT, nScriptType ); +/*N*/ USHORT nWhich_Italic = GetScriptItemId( EE_CHAR_ITALIC, nScriptType ); +/*N*/ +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( nWhich_FontInfo ) == SFX_ITEM_ON ) ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)rSet.Get( nWhich_FontInfo ); +/*N*/ rFont.SetName( rFontItem.GetFamilyName() ); +/*N*/ rFont.SetFamily( rFontItem.GetFamily() ); +/*N*/ rFont.SetPitch( rFontItem.GetPitch() ); +/*N*/ rFont.SetCharSet( rFontItem.GetCharSet() ); +/*N*/ } +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( nWhich_Language ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetLanguage( ((const SvxLanguageItem&)rSet.Get( nWhich_Language )).GetLanguage() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_COLOR ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetColor( ((const SvxColorItem&)rSet.Get( EE_CHAR_COLOR )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( nWhich_FontHeight ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetSize( Size( rFont.GetSize().Width(), ((const SvxFontHeightItem&)rSet.Get( nWhich_FontHeight ) ).GetHeight() ) ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( nWhich_Weight ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetWeight( ((const SvxWeightItem&)rSet.Get( nWhich_Weight )).GetWeight() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_UNDERLINE ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetUnderline( ((const SvxUnderlineItem&)rSet.Get( EE_CHAR_UNDERLINE )).GetUnderline() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_STRIKEOUT ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetStrikeout( ((const SvxCrossedOutItem&)rSet.Get( EE_CHAR_STRIKEOUT )).GetStrikeout() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( nWhich_Italic ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetItalic( ((const SvxPostureItem&)rSet.Get( nWhich_Italic )).GetPosture() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_OUTLINE ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetOutline( ((const SvxContourItem&)rSet.Get( EE_CHAR_OUTLINE )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_SHADOW ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetShadow( ((const SvxShadowedItem&)rSet.Get( EE_CHAR_SHADOW )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_ESCAPEMENT ) == SFX_ITEM_ON ) ) +/*N*/ { +/*N*/ const SvxEscapementItem& rEsc = (const SvxEscapementItem&) rSet.Get( EE_CHAR_ESCAPEMENT ); +/*N*/ +/*N*/ USHORT nProp = rEsc.GetProp(); +/*N*/ rFont.SetPropr( (BYTE)nProp ); +/*N*/ +/*N*/ short nEsc = rEsc.GetEsc(); +/*N*/ if ( nEsc == DFLT_ESC_AUTO_SUPER ) +/*N*/ nEsc = 100 - nProp; +/*N*/ else if ( nEsc == DFLT_ESC_AUTO_SUB ) +/*N*/ nEsc = -( 100 - nProp ); +/*N*/ rFont.SetEscapement( nEsc ); +/*N*/ } +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_PAIRKERNING ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetKerning( ((const SvxAutoKernItem&)rSet.Get( EE_CHAR_PAIRKERNING )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_KERNING ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetFixKerning( ((const SvxKerningItem&)rSet.Get( EE_CHAR_KERNING )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_WLM ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetWordLineMode( ((const SvxWordLineModeItem&)rSet.Get( EE_CHAR_WLM )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_EMPHASISMARK ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetEmphasisMark( ((const SvxEmphasisMarkItem&)rSet.Get( EE_CHAR_EMPHASISMARK )).GetValue() ); +/*N*/ if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_RELIEF ) == SFX_ITEM_ON ) ) +/*N*/ rFont.SetRelief( (FontRelief)((const SvxCharReliefItem&)rSet.Get( EE_CHAR_RELIEF )).GetValue() ); +/*N*/ +/*N*/ // Ob ich jetzt den ganzen Font vergleiche, oder vor jeder Aenderung +/*N*/ // pruefe, ob der Wert sich aendert, bleibt sich relativ gleich. +/*N*/ // So ggf ein MakeUniqFont im Font mehr, dafuer bei Aenderung schnellerer +/*N*/ // Abbruch der Abfrage, oder ich musste noch jedesmal ein bChanged pflegen. +/*N*/ if ( rFont == aPrevFont ) +/*N*/ rFont = aPrevFont; // => Gleicher ImpPointer fuer IsSameInstance +/*N*/ } + +/*N*/ void EditDoc::CreateDefFont( BOOL bUseStyles ) +/*N*/ { +/*N*/ SfxItemSet aTmpSet( GetItemPool(), EE_PARA_START, EE_CHAR_END ); +/*N*/ CreateFont( aDefFont, aTmpSet ); +/*N*/ aDefFont.SetVertical( IsVertical() ); +/*N*/ aDefFont.SetOrientation( IsVertical() ? 2700 : 0 ); +/*N*/ +/*N*/ for ( USHORT nNode = 0; nNode < Count(); nNode++ ) +/*N*/ { +/*N*/ ContentNode* pNode = GetObject( nNode ); +/*N*/ pNode->GetCharAttribs().GetDefFont() = aDefFont; +/*N*/ if ( bUseStyles ) +/*?*/ pNode->CreateDefFont(); +/*N*/ } +/*N*/ } + +/*N*/ static const sal_Unicode aCR[] = { 0x0d, 0x00 }; +/*N*/ static const sal_Unicode aLF[] = { 0x0a, 0x00 }; +/*N*/ static const sal_Unicode aCRLF[] = { 0x0d, 0x0a, 0x00 }; + +/*N*/ XubString EditDoc::GetSepStr( LineEnd eEnd ) +/*N*/ { +/*N*/ XubString aSep; +/*N*/ if ( eEnd == LINEEND_CR ) +/*N*/ aSep = aCR; +/*N*/ else if ( eEnd == LINEEND_LF ) +/*N*/ aSep = aLF; +/*N*/ else +/*N*/ aSep = aCRLF; +/*N*/ return aSep; +/*N*/ } + +/*N*/ XubString EditDoc::GetText( LineEnd eEnd ) const +/*N*/ { +/*N*/ ULONG nLen = GetTextLen(); +/*N*/ USHORT nNodes = Count(); +/*N*/ +/*N*/ String aSep = EditDoc::GetSepStr( eEnd ); +/*N*/ USHORT nSepSize = aSep.Len(); +/*N*/ +/*N*/ if ( nSepSize ) +/*N*/ nLen += nNodes * nSepSize; +/*N*/ if ( nLen > 0xFFFb / sizeof(xub_Unicode) ) +/*N*/ { +/*?*/ DBG_ERROR( "Text zu gross fuer String" ); +/*?*/ return XubString(); +/*N*/ } +/*N*/ xub_Unicode* pStr = new xub_Unicode[nLen+1]; +/*N*/ xub_Unicode* pCur = pStr; +/*N*/ USHORT nLastNode = nNodes-1; +/*N*/ for ( USHORT nNode = 0; nNode < nNodes; nNode++ ) +/*N*/ { +/*N*/ XubString aTmp( GetParaAsString( GetObject(nNode) ) ); +/*N*/ memcpy( pCur, aTmp.GetBuffer(), aTmp.Len()*sizeof(sal_Unicode) ); +/*N*/ pCur += aTmp.Len(); +/*N*/ if ( nSepSize && ( nNode != nLastNode ) ) +/*N*/ { +/*N*/ memcpy( pCur, aSep.GetBuffer(), nSepSize*sizeof(sal_Unicode ) ); +/*N*/ pCur += nSepSize; +/*N*/ } +/*N*/ } +/*N*/ *pCur = '\0'; +/*N*/ XubString aASCIIText( pStr ); +/*N*/ delete[] pStr; +/*N*/ return aASCIIText; +/*N*/ } + +/*N*/ XubString EditDoc::GetParaAsString( USHORT nNode ) const +/*N*/ { +/*N*/ return GetParaAsString( SaveGetObject( nNode ) ); +/*N*/ } + +/*N*/ XubString EditDoc::GetParaAsString( ContentNode* pNode, USHORT nStartPos, USHORT nEndPos, BOOL bResolveFields ) const +/*N*/ { +/*N*/ if ( nEndPos > pNode->Len() ) +/*N*/ nEndPos = pNode->Len(); +/*N*/ +/*N*/ DBG_ASSERT( nStartPos <= nEndPos, "Start und Ende vertauscht?" ); +/*N*/ +/*N*/ USHORT nIndex = nStartPos; +/*N*/ XubString aStr; +/*N*/ EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( nIndex ); +/*N*/ while ( nIndex < nEndPos ) +/*N*/ { +/*N*/ USHORT nEnd = nEndPos; +/*N*/ if ( pNextFeature && ( pNextFeature->GetStart() < nEnd ) ) +/*N*/ nEnd = pNextFeature->GetStart(); +/*N*/ else +/*N*/ pNextFeature = 0; // Feature interessiert unten nicht +/*N*/ +/*N*/ +/*N*/ DBG_ASSERT( nEnd >= nIndex, "Ende vorm Index?" ); +/*N*/ aStr += XubString( *pNode, nIndex, nEnd-nIndex ); +/*N*/ +/*N*/ if ( pNextFeature ) +/*N*/ { +/*N*/ switch ( pNextFeature->GetItem()->Which() ) +/*N*/ { +/*N*/ case EE_FEATURE_TAB: aStr += '\t'; +/*N*/ break; +/*N*/ case EE_FEATURE_LINEBR: aStr += '\x0A'; +/*N*/ break; +/*N*/ case EE_FEATURE_FIELD: if ( bResolveFields ) +/*N*/ aStr += ((EditCharAttribField*)pNextFeature)->GetFieldValue(); +/*N*/ break; +/*N*/ default: DBG_ERROR( "Was fuer ein Feature ?" ); +/*N*/ } +/*N*/ pNextFeature = pNode->GetCharAttribs().FindFeature( ++nEnd ); +/*N*/ } +/*N*/ nIndex = nEnd; +/*N*/ } +/*N*/ return aStr; +/*N*/ } + +/*N*/ ULONG EditDoc::GetTextLen() const +/*N*/ { +/*N*/ ULONG nLen = 0; +/*N*/ for ( USHORT nNode = 0; nNode < Count(); nNode++ ) +/*N*/ { +/*N*/ ContentNode* pNode = GetObject( nNode ); +/*N*/ nLen += pNode->Len(); +/*N*/ // Felder knnen laenger sein als der Platzhalter im Node. +/*N*/ const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ for ( USHORT nAttr = rAttrs.Count(); nAttr; ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttrs[--nAttr]; +/*N*/ if ( pAttr->Which() == EE_FEATURE_FIELD ) +/*N*/ { +/*N*/ USHORT nFieldLen = ((EditCharAttribField*)pAttr)->GetFieldValue().Len(); +/*N*/ if ( !nFieldLen ) +/*N*/ nLen--; +/*N*/ else +/*N*/ nLen += nFieldLen-1; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nLen; +/*N*/ } + +/*N*/ EditPaM EditDoc::Clear() +/*N*/ { +/*N*/ ImplDestroyContents(); +/*N*/ +/*N*/ ContentNode* pNode = new ContentNode( GetItemPool() ); +/*N*/ Insert( pNode, 0 ); +/*N*/ +/*N*/ CreateDefFont( FALSE ); +/*N*/ +/*N*/ SetModified( FALSE ); +/*N*/ +/*N*/ EditPaM aPaM( pNode, 0 ); +/*N*/ return aPaM; +/*N*/ } +/*N*/ +/*N*/ void EditDoc::SetModified( BOOL b ) +/*N*/ { +/*N*/ bModified = b; +/*N*/ if ( bModified ) +/*N*/ { +/*N*/ aModifyHdl.Call( NULL ); +/*N*/ } +/*N*/ } + +/*N*/ EditPaM EditDoc::RemoveText() +/*N*/ { +/*N*/ // Das alte ItemSetmerken, damit z.B. im Chart Font behalten bleibt +/*N*/ ContentNode* pPrevFirstNode = GetObject(0); +/*N*/ SfxStyleSheet* pPrevStyle = pPrevFirstNode->GetStyleSheet(); +/*N*/ SfxItemSet aPrevSet( pPrevFirstNode->GetContentAttribs().GetItems() ); +/*N*/ Font aPrevFont( pPrevFirstNode->GetCharAttribs().GetDefFont() ); +/*N*/ +/*N*/ ImplDestroyContents(); +/*N*/ +/*N*/ ContentNode* pNode = new ContentNode( GetItemPool() ); +/*N*/ Insert( pNode, 0 ); +/*N*/ +/*N*/ pNode->SetStyleSheet( pPrevStyle, FALSE ); +/*N*/ pNode->GetContentAttribs().GetItems().Set( aPrevSet ); +/*N*/ pNode->GetCharAttribs().GetDefFont() = aPrevFont; +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ EditPaM aPaM( pNode, 0 ); +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM EditDoc::InsertText( EditPaM aPaM, const XubString& rStr ) +/*N*/ { +/*N*/ DBG_ASSERT( rStr.Search( 0x0A ) == STRING_NOTFOUND, "EditDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" ); +/*N*/ DBG_ASSERT( rStr.Search( 0x0D ) == STRING_NOTFOUND, "EditDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" ); +/*N*/ DBG_ASSERT( rStr.Search( '\t' ) == STRING_NOTFOUND, "EditDoc::InsertText: Zeilentrenner in Absatz nicht erlaubt!" ); +/*N*/ DBG_ASSERT( aPaM.GetNode(), "Blinder PaM in EditDoc::InsertText1" ); +/*N*/ +/*N*/ aPaM.GetNode()->Insert( rStr, aPaM.GetIndex() ); +/*N*/ aPaM.GetNode()->ExpandAttribs( aPaM.GetIndex(), rStr.Len(), GetItemPool() ); +/*N*/ aPaM.GetIndex() += rStr.Len(); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, BOOL bKeepEndingAttribs ) +/*N*/ { +/*N*/ DBG_ASSERT( aPaM.GetNode(), "Blinder PaM in EditDoc::InsertParaBreak" ); +/*N*/ ContentNode* pCurNode = aPaM.GetNode(); +/*N*/ USHORT nPos = GetPos( pCurNode ); +/*N*/ XubString aStr = aPaM.GetNode()->Copy( aPaM.GetIndex() ); +/*N*/ aPaM.GetNode()->Erase( aPaM.GetIndex() ); +/*N*/ +/*N*/ // ContenNode-CTOR kopiert auch die Absatzattribute +/*N*/ ContentNode* pNode = new ContentNode( aStr, aPaM.GetNode()->GetContentAttribs()); +/*N*/ // Den Default-Font kopieren +/*N*/ pNode->GetCharAttribs().GetDefFont() = aPaM.GetNode()->GetCharAttribs().GetDefFont(); +/*N*/ SfxStyleSheet* pStyle = aPaM.GetNode()->GetStyleSheet(); +/*N*/ if ( pStyle ) +/*N*/ { +/*N*/ XubString aFollow( pStyle->GetFollow() ); +/*N*/ if ( aFollow.Len() && ( aFollow != pStyle->GetName() ) ) +/*N*/ { +/*?*/ SfxStyleSheetBase* pNext = pStyle->GetPool().Find( aFollow, pStyle->GetFamily() ); +/*?*/ pNode->SetStyleSheet( (SfxStyleSheet*)pNext ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Zeichenattribute muessen ggf. kopiert bzw gestutzt werden: +/*N*/ pNode->CopyAndCutAttribs( aPaM.GetNode(), GetItemPool(), bKeepEndingAttribs ); +/*N*/ +/*N*/ Insert( pNode, nPos+1 ); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ aPaM.SetNode( pNode ); +/*N*/ aPaM.SetIndex( 0 ); +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM EditDoc::InsertFeature( EditPaM aPaM, const SfxPoolItem& rItem ) +/*N*/ { +/*N*/ DBG_ASSERT( aPaM.GetNode(), "Blinder PaM in EditDoc::InsertFeature" ); +/*N*/ +/*N*/ aPaM.GetNode()->Insert( CH_FEATURE, aPaM.GetIndex() ); +/*N*/ aPaM.GetNode()->ExpandAttribs( aPaM.GetIndex(), 1, GetItemPool() ); +/*N*/ +/*N*/ // Fuer das Feature ein Feature-Attribut anlegen... +/*N*/ EditCharAttrib* pAttrib = MakeCharAttrib( GetItemPool(), rItem, aPaM.GetIndex(), aPaM.GetIndex()+1 ); +/*N*/ DBG_ASSERT( pAttrib, "Warum kann ich kein Feature anlegen ?" ); +/*N*/ aPaM.GetNode()->GetCharAttribs().InsertAttrib( pAttrib ); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ aPaM.GetIndex()++; +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM EditDoc::ConnectParagraphs( ContentNode* pLeft, ContentNode* pRight ) +/*N*/ { +/*N*/ const EditPaM aPaM( pLeft, pLeft->Len() ); +/*N*/ +/*N*/ // Erst die Attribute, da sonst nLen nicht stimmt! +/*N*/ pLeft->AppendAttribs( pRight ); +/*N*/ // Dann den Text... +/*N*/ *pLeft += *pRight; +/*N*/ +/*N*/ // der rechte verschwindet. +/*N*/ RemoveItemsFromPool( pRight ); +/*N*/ USHORT nRight = GetPos( pRight ); +/*N*/ Remove( nRight ); +/*N*/ delete pRight; +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM EditDoc::RemoveChars( EditPaM aPaM, USHORT nChars ) +/*N*/ { +/*N*/ // Evtl. Features entfernen! +/*N*/ aPaM.GetNode()->Erase( aPaM.GetIndex(), nChars ); +/*N*/ aPaM.GetNode()->CollapsAttribs( aPaM.GetIndex(), nChars, GetItemPool() ); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ void EditDoc::InsertAttribInSelection( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem ) +/*N*/ { +/*N*/ DBG_ASSERT( pNode, "Wohin mit dem Attribut?" ); +/*N*/ DBG_ASSERT( nEnd <= pNode->Len(), "InsertAttrib: Attribut zu gross!" ); +/*N*/ +/*N*/ // fuer Optimierung: +/*N*/ // dieses endet am Anfang der Selektion => kann erweitert werden +/*N*/ EditCharAttrib* pEndingAttrib = 0; +/*N*/ // dieses startet am Ende der Selektion => kann erweitert werden +/*N*/ EditCharAttrib* pStartingAttrib = 0; +/*N*/ +/*N*/ DBG_ASSERT( nStart <= nEnd, "Kleiner Rechenfehler in InsertAttribInSelection" ); +/*N*/ +/*N*/ RemoveAttribs( pNode, nStart, nEnd, pStartingAttrib, pEndingAttrib, rPoolItem.Which() ); +/*N*/ +/*N*/ if ( pStartingAttrib && pEndingAttrib && +/*N*/ ( *(pStartingAttrib->GetItem()) == rPoolItem ) && +/*N*/ ( *(pEndingAttrib->GetItem()) == rPoolItem ) ) +/*N*/ { +/*?*/ // wird ein groesses Attribut. +/*?*/ pEndingAttrib->GetEnd() = pStartingAttrib->GetEnd(); +/*?*/ GetItemPool().Remove( *(pStartingAttrib->GetItem()) ); +/*?*/ pNode->GetCharAttribs().GetAttribs().Remove( pNode->GetCharAttribs().GetAttribs().GetPos( pStartingAttrib ) ); +/*?*/ delete pStartingAttrib; +/*N*/ } +/*N*/ else if ( pStartingAttrib && ( *(pStartingAttrib->GetItem()) == rPoolItem ) ) +/*?*/ pStartingAttrib->GetStart() = nStart; +/*N*/ else if ( pEndingAttrib && ( *(pEndingAttrib->GetItem()) == rPoolItem ) ) +/*N*/ pEndingAttrib->GetEnd() = nEnd; +/*N*/ else +/*N*/ InsertAttrib( rPoolItem, pNode, nStart, nEnd ); +/*N*/ +/*N*/ if ( pStartingAttrib ) +/*?*/ pNode->GetCharAttribs().ResortAttribs(); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ } + + +/*N*/ BOOL EditDoc::RemoveAttribs( ContentNode* pNode, USHORT nStart, USHORT nEnd, EditCharAttrib*& rpStarting, EditCharAttrib*& rpEnding, USHORT nWhich ) +/*N*/ { +/*N*/ DBG_ASSERT( pNode, "Wohin mit dem Attribut?" ); +/*N*/ DBG_ASSERT( nEnd <= pNode->Len(), "InsertAttrib: Attribut zu gross!" ); +/*N*/ +/*N*/ // dieses endet am Anfang der Selektion => kann erweitert werden +/*N*/ rpEnding = 0; +/*N*/ // dieses startet am Ende der Selektion => kann erweitert werden +/*N*/ rpStarting = 0; +/*N*/ +/*N*/ BOOL bChanged = FALSE; +/*N*/ +/*N*/ DBG_ASSERT( nStart <= nEnd, "Kleiner Rechenfehler in InsertAttribInSelection" ); +/*N*/ +/*N*/ // ueber die Attribute iterieren... +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ BOOL bRemoveAttrib = FALSE; +/*N*/ // MT 11.9.97: +/*N*/ // Ich denke dass in dieser Methode generell keine Features geloescht +/*N*/ // werden sollen. +/*N*/ // => Dann koennen die Feature-Abfragen weiter unten entfallen +/*N*/ USHORT nAttrWhich = pAttr->Which(); +/*N*/ if ( ( nAttrWhich < EE_FEATURE_START ) && ( !nWhich || ( nAttrWhich == nWhich ) ) ) +/*N*/ { +/*N*/ // Attribut beginnt in Selection +/*N*/ if ( ( pAttr->GetStart() >= nStart ) && ( pAttr->GetStart() <= nEnd ) ) +/*N*/ { +/*?*/ bChanged = TRUE; +/*?*/ if ( pAttr->GetEnd() > nEnd ) +/*?*/ { +/*?*/ pAttr->GetStart() = nEnd; // dann faengt es dahinter an +/*?*/ rpStarting = pAttr; +/*?*/ break; // es kann kein weiteres Attrib hier liegen +/*?*/ } +/*?*/ else if ( !pAttr->IsFeature() || ( pAttr->GetStart() == nStart ) ) +/*?*/ { +/*?*/ // Feature nur loeschen, wenn genau an der Stelle +/*?*/ bRemoveAttrib = TRUE; +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ // Attribut endet in Selection +/*N*/ else if ( ( pAttr->GetEnd() >= nStart ) && ( pAttr->GetEnd() <= nEnd ) ) +/*N*/ { +/*N*/ bChanged = TRUE; +/*N*/ if ( ( pAttr->GetStart() < nStart ) && !pAttr->IsFeature() ) +/*N*/ { +/*N*/ pAttr->GetEnd() = nStart; // dann hoert es hier auf +/*N*/ rpEnding = pAttr; +/*N*/ } +/*N*/ else if ( !pAttr->IsFeature() || ( pAttr->GetStart() == nStart ) ) +/*N*/ { +/*N*/ // Feature nur loeschen, wenn genau an der Stelle +/*N*/ bRemoveAttrib = TRUE; +/*N*/ } +/*N*/ } +/*N*/ // Attribut ueberlappt die Selektion +/*N*/ else if ( ( pAttr->GetStart() <= nStart ) && ( pAttr->GetEnd() >= nEnd ) ) +/*N*/ { +/*?*/ bChanged = TRUE; +/*?*/ if ( pAttr->GetStart() == nStart ) +/*?*/ { +/*?*/ pAttr->GetStart() = nEnd; +/*?*/ rpStarting = pAttr; +/*?*/ break; // es kann weitere Attribute geben! +/*?*/ } +/*?*/ else if ( pAttr->GetEnd() == nEnd ) +/*?*/ { +/*?*/ pAttr->GetEnd() = nStart; +/*?*/ rpEnding = pAttr; +/*?*/ break; // es kann weitere Attribute geben! +/*?*/ } +/*?*/ else // Attribut muss gesplittet werden... +/*?*/ { +/*?*/ USHORT nOldEnd = pAttr->GetEnd(); +/*?*/ pAttr->GetEnd() = nStart; +/*?*/ rpEnding = pAttr; +/*?*/ InsertAttrib( *pAttr->GetItem(), pNode, nEnd, nOldEnd ); +/*?*/ break; // es kann weitere Attribute geben! +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ if ( bRemoveAttrib ) +/*N*/ { +/*?*/ DBG_ASSERT( ( pAttr != rpStarting ) && ( pAttr != rpEnding ), "Loeschen und behalten des gleichen Attributs ?" ); +/*?*/ DBG_ASSERT( !pAttr->IsFeature(), "RemoveAttribs: Remove a feature?!" ); +/*?*/ pNode->GetCharAttribs().GetAttribs().Remove(nAttr); +/*?*/ GetItemPool().Remove( *pAttr->GetItem() ); +/*?*/ delete pAttr; +/*?*/ nAttr--; +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ +/*N*/ if ( bChanged ) +/*N*/ SetModified( TRUE ); +/*N*/ +/*N*/ return bChanged; +/*N*/ } + +/*N*/ void EditDoc::InsertAttrib( const SfxPoolItem& rPoolItem, ContentNode* pNode, USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ // Diese Methode prueft nicht mehr, ob ein entspr. Attribut +/*N*/ // schon an der Stelle existiert! +/*N*/ +/*N*/ EditCharAttrib* pAttrib = MakeCharAttrib( GetItemPool(), rPoolItem, nStart, nEnd ); +/*N*/ DBG_ASSERT( pAttrib, "MakeCharAttrib fehlgeschlagen!" ); +/*N*/ pNode->GetCharAttribs().InsertAttrib( pAttrib ); +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ } + +/*N*/ void EditDoc::InsertAttrib( ContentNode* pNode, USHORT nStart, USHORT nEnd, const SfxPoolItem& rPoolItem ) +/*N*/ { +/*N*/ if ( nStart != nEnd ) +/*N*/ { +/*N*/ InsertAttribInSelection( pNode, nStart, nEnd, rPoolItem ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Pruefen, ob schon ein neues Attribut mit der WhichId an der Stelle: +/*N*/ EditCharAttrib* pAttr = pNode->GetCharAttribs().FindEmptyAttrib( rPoolItem.Which(), nStart ); +/*N*/ if ( pAttr ) +/*N*/ { +/*?*/ // Attribut entfernen.... +/*?*/ pNode->GetCharAttribs().GetAttribs().Remove( +/*?*/ pNode->GetCharAttribs().GetAttribs().GetPos( pAttr ) ); +/*N*/ } +/*N*/ +/*N*/ // pruefen, ob ein 'gleiches' Attribut an der Stelle liegt. +/*N*/ pAttr = pNode->GetCharAttribs().FindAttrib( rPoolItem.Which(), nStart ); +/*N*/ if ( pAttr ) +/*N*/ { +/*?*/ if ( pAttr->IsInside( nStart ) ) // splitten +/*?*/ { +/*?*/ // ??????????????????????????????? +/*?*/ // eigentlich noch pruefen, ob wirklich splittet, oder return ! +/*?*/ // ??????????????????????????????? +/*?*/ USHORT nOldEnd = pAttr->GetEnd(); +/*?*/ pAttr->GetEnd() = nStart; +/*?*/ pAttr = MakeCharAttrib( GetItemPool(), *(pAttr->GetItem()), nStart, nOldEnd ); +/*?*/ pNode->GetCharAttribs().InsertAttrib( pAttr ); +/*?*/ } +/*?*/ else if ( pAttr->GetEnd() == nStart ) +/*?*/ { +/*?*/ DBG_ASSERT( !pAttr->IsEmpty(), "Doch noch ein leeres Attribut?" ); +/*?*/ // pruefen, ob genau das gleiche Attribut +/*?*/ if ( *(pAttr->GetItem()) == rPoolItem ) +/*?*/ return; +/*?*/ } +/*N*/ } +/*N*/ InsertAttrib( rPoolItem, pNode, nStart, nStart ); +/*N*/ } +/*N*/ +/*N*/ SetModified( TRUE ); +/*N*/ } + +/*N*/ void EditDoc::FindAttribs( ContentNode* pNode, USHORT nStartPos, USHORT nEndPos, SfxItemSet& rCurSet ) +/*N*/ { +/*N*/ DBG_ASSERT( pNode, "Wo soll ich suchen ?" ); +/*N*/ DBG_ASSERT( nStartPos <= nEndPos, "Ungueltiger Bereich!" ); +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ // keine Selection... +/*N*/ if ( nStartPos == nEndPos ) +/*N*/ { +/*N*/ while ( pAttr && ( pAttr->GetStart() <= nEndPos) ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem = 0; +/*N*/ // Attribut liegt dadrueber... +/*N*/ if ( ( pAttr->GetStart() < nStartPos ) && ( pAttr->GetEnd() > nStartPos ) ) +/*?*/ pItem = pAttr->GetItem(); +/*N*/ // Attribut endet hier, ist nicht leer +/*N*/ else if ( ( pAttr->GetStart() < nStartPos ) && ( pAttr->GetEnd() == nStartPos ) ) +/*N*/ { +/*?*/ if ( !pNode->GetCharAttribs().FindEmptyAttrib( pAttr->GetItem()->Which(), nStartPos ) ) +/*?*/ pItem = pAttr->GetItem(); +/*N*/ } +/*N*/ // Attribut endet hier, ist leer +/*N*/ else if ( ( pAttr->GetStart() == nStartPos ) && ( pAttr->GetEnd() == nStartPos ) ) +/*N*/ { +/*?*/ pItem = pAttr->GetItem(); +/*N*/ } +/*N*/ // Attribut beginnt hier +/*N*/ else if ( ( pAttr->GetStart() == nStartPos ) && ( pAttr->GetEnd() > nStartPos ) ) +/*N*/ { +/*N*/ if ( nStartPos == 0 ) // Sonderfall +/*N*/ pItem = pAttr->GetItem(); +/*N*/ } +/*N*/ +/*N*/ if ( pItem ) +/*N*/ { +/*N*/ USHORT nWhich = pItem->Which(); +/*N*/ if ( rCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) +/*N*/ { +/*N*/ rCurSet.Put( *pItem ); +/*N*/ } +/*N*/ else if ( rCurSet.GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ const SfxPoolItem& rItem = rCurSet.Get( nWhich ); +/*?*/ if ( rItem != *pItem ) +/*?*/ { +/*?*/ rCurSet.InvalidateItem( nWhich ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ } +/*N*/ else // Selektion +/*N*/ { +/*N*/ while ( pAttr && ( pAttr->GetStart() < nEndPos) ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem = 0; +/*N*/ // Attribut liegt dadrueber... +/*N*/ if ( ( pAttr->GetStart() <= nStartPos ) && ( pAttr->GetEnd() >= nEndPos ) ) +/*N*/ pItem = pAttr->GetItem(); +/*N*/ // Attribut startet mitten drin... +/*N*/ else if ( pAttr->GetStart() >= nStartPos ) +/*N*/ { +/*N*/ // !!! pItem = pAttr->GetItem(); +/*N*/ // einfach nur pItem reicht nicht, da ich z.B. bei Shadow +/*N*/ // niemals ein ungleiches Item finden wuerde, da ein solche +/*N*/ // seine Anwesenheit durch Abwesenheit repraesentiert! +/*N*/ // if ( ... ) +/*N*/ // Es muesste geprueft werden, on genau das gleiche Attribut +/*N*/ // an der Bruchstelle aufsetzt, was recht aufwendig ist. +/*N*/ // Da ich beim Einfuegen von Attributen aber etwas optimiere +/*N*/ // tritt der Fall nicht so schnell auf... +/*N*/ // Also aus Geschwindigkeitsgruenden: +/*N*/ rCurSet.InvalidateItem( pAttr->GetItem()->Which() ); +/*N*/ +/*N*/ } +/*N*/ // Attribut endet mitten drin... +/*N*/ else if ( pAttr->GetEnd() > nStartPos ) +/*N*/ { +/*N*/ // pItem = pAttr->GetItem(); +/*N*/ // s.o. + /*-----------------31.05.95 16:01------------------- + Ist falsch, wenn das gleiche Attribut sofort wieder + eingestellt wird! + => Sollte am besten nicht vorkommen, also gleich beim + Setzen von Attributen richtig machen! + --------------------------------------------------*/ +/*?*/ rCurSet.InvalidateItem( pAttr->GetItem()->Which() ); +/*N*/ } +/*N*/ +/*N*/ if ( pItem ) +/*N*/ { +/*N*/ USHORT nWhich = pItem->Which(); +/*N*/ if ( rCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) +/*N*/ { +/*N*/ rCurSet.Put( *pItem ); +/*N*/ } +/*N*/ else if ( rCurSet.GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ const SfxPoolItem& rItem = rCurSet.Get( nWhich ); +/*?*/ if ( rItem != *pItem ) +/*?*/ { +/*?*/ rCurSet.InvalidateItem( nWhich ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ } +/*N*/ } + + +// ------------------------------------------------------------------------- +// class EditCharAttribList +// ------------------------------------------------------------------------- + +/*N*/ CharAttribList::CharAttribList() +/*N*/ { +/*N*/ DBG_CTOR( EE_CharAttribList, 0 ); +/*N*/ bHasEmptyAttribs = FALSE; +/*N*/ } + +/*N*/ CharAttribList::~CharAttribList() +/*N*/ { +/*N*/ DBG_DTOR( EE_CharAttribList, 0 ); +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ delete pAttr; +/*N*/ ++nAttr; +/*N*/ pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ } +/*N*/ Clear(); +/*N*/ } + +/*N*/ void CharAttribList::InsertAttrib( EditCharAttrib* pAttrib ) +/*N*/ { +/*N*/ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ // optimieren: binaere Suche ? ! +/*N*/ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ +/*N*/ // MT: 26.11.98 +/*N*/ // Vielleicht aber auch einfach nur rueckwaerts iterieren: +/*N*/ // Der haeufigste und kritischste Fall: Attribute kommen bereits +/*N*/ // sortiert an (InsertBinTextObject!) +/*N*/ // Hier waere auch binaere Suche nicht optimal. +/*N*/ // => Wuerde einiges bringen! +/*N*/ +/*N*/ const USHORT nCount = Count(); +/*N*/ const USHORT nStart = pAttrib->GetStart(); // vielleicht besser fuer Comp.Opt. +/*N*/ +/*N*/ if ( pAttrib->IsEmpty() ) +/*N*/ bHasEmptyAttribs = TRUE; +/*N*/ +/*N*/ BOOL bInserted = FALSE; +/*N*/ for ( USHORT x = 0; x < nCount; x++ ) +/*N*/ { +/*N*/ EditCharAttribPtr pCurAttrib = aAttribs[x]; +/*N*/ if ( pCurAttrib->GetStart() > nStart ) +/*N*/ { +/*N*/ aAttribs.Insert( pAttrib, x ); +/*N*/ bInserted = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ if ( !bInserted ) +/*N*/ aAttribs.Insert( pAttrib, nCount ); +/*N*/ } + +/*N*/ void CharAttribList::ResortAttribs() +/*N*/ { +/*N*/ if ( Count() ) +/*N*/ { +/*N*/ qsort( (void*)aAttribs.GetData(), aAttribs.Count(), sizeof( EditCharAttrib* ), CompareStart ); +/*N*/ } +/*N*/ } + +/*N*/ void CharAttribList::OptimizeRanges( SfxItemPool& rItemPool ) +/*N*/ { +/*N*/ for ( USHORT n = 0; n < aAttribs.Count(); n++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = aAttribs.GetObject( n ); +/*N*/ for ( USHORT nNext = n+1; nNext < aAttribs.Count(); nNext++ ) +/*N*/ { +/*N*/ EditCharAttrib* p = aAttribs.GetObject( nNext ); +/*N*/ if ( !pAttr->IsFeature() && ( p->GetStart() == pAttr->GetEnd() ) && ( p->Which() == pAttr->Which() ) ) +/*N*/ { +/*N*/ if ( *p->GetItem() == *pAttr->GetItem() ) +/*N*/ { +/*N*/ pAttr->GetEnd() = p->GetEnd(); +/*N*/ aAttribs.Remove( nNext ); +/*N*/ rItemPool.Remove( *p->GetItem() ); +/*N*/ delete p; +/*N*/ } +/*N*/ break; // only 1 attr with same which can start here. +/*N*/ } +/*N*/ else if ( p->GetStart() > pAttr->GetEnd() ) +/*N*/ { +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ EditCharAttrib* CharAttribList::FindAttrib( USHORT nWhich, USHORT nPos ) +/*N*/ { +/*N*/ // Rueckwaerts, falls eins dort endet, das naechste startet. +/*N*/ // => Das startende gilt... +/*N*/ USHORT nAttr = aAttribs.Count()-1; +/*N*/ EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ if ( ( pAttr->Which() == nWhich ) && pAttr->IsIn(nPos) ) +/*N*/ return pAttr; +/*N*/ pAttr = GetAttrib( aAttribs, --nAttr ); +/*N*/ } +/*N*/ return 0; +/*N*/ } + +/*N*/ EditCharAttrib* CharAttribList::FindNextAttrib( USHORT nWhich, USHORT nFromPos ) const +/*N*/ { +/*N*/ DBG_ASSERT( nWhich, "FindNextAttrib: Which?" ); +/*N*/ const USHORT nAttribs = aAttribs.Count(); +/*N*/ for ( USHORT nAttr = 0; nAttr < nAttribs; nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = aAttribs[ nAttr ]; +/*N*/ if ( ( pAttr->GetStart() >= nFromPos ) && ( pAttr->Which() == nWhich ) ) +/*N*/ return pAttr; +/*N*/ } +/*N*/ return 0; +/*N*/ } + + + + +/*N*/ BOOL CharAttribList::HasBoundingAttrib( USHORT nBound ) +/*N*/ { +/*N*/ // Rueckwaerts, falls eins dort endet, das naechste startet. +/*N*/ // => Das startende gilt... +/*N*/ USHORT nAttr = aAttribs.Count()-1; +/*N*/ EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ while ( pAttr && ( pAttr->GetEnd() >= nBound ) ) +/*N*/ { +/*?*/ if ( ( pAttr->GetStart() == nBound ) || ( pAttr->GetEnd() == nBound ) ) +/*?*/ return TRUE; +/*?*/ pAttr = GetAttrib( aAttribs, --nAttr ); +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ EditCharAttrib* CharAttribList::FindEmptyAttrib( USHORT nWhich, USHORT nPos ) +/*N*/ { +/*N*/ if ( !bHasEmptyAttribs ) +/*N*/ return 0; +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ while ( pAttr && ( pAttr->GetStart() <= nPos ) ) +/*N*/ { +/*N*/ if ( ( pAttr->GetStart() == nPos ) && ( pAttr->GetEnd() == nPos ) && ( pAttr->Which() == nWhich ) ) +/*N*/ return pAttr; +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( aAttribs, nAttr ); +/*N*/ } +/*N*/ return 0; +/*N*/ } + +/*N*/ EditCharAttrib* CharAttribList::FindFeature( USHORT nPos ) const +/*N*/ { +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttrib* pNextAttrib = GetAttrib( aAttribs, nAttr ); +/*N*/ +/*N*/ // erstmal zur gewuenschten Position... +/*N*/ while ( pNextAttrib && ( pNextAttrib->GetStart() < nPos ) ) +/*N*/ { +/*N*/ nAttr++; +/*N*/ pNextAttrib = GetAttrib( aAttribs, nAttr ); +/*N*/ } +/*N*/ +/*N*/ // jetzt das Feature suchen... +/*N*/ while ( pNextAttrib && !pNextAttrib->IsFeature() ) +/*N*/ { +/*N*/ nAttr++; +/*N*/ pNextAttrib = GetAttrib( aAttribs, nAttr ); +/*N*/ } +/*N*/ +/*N*/ return pNextAttrib; +/*N*/ } + + + + + + + + + + + + +/*N*/ EditEngineItemPool::EditEngineItemPool( BOOL bPersistenRefCounts ) +/*N*/ : SfxItemPool( String( "EditEngineItemPool", RTL_TEXTENCODING_ASCII_US ), EE_ITEMS_START, EE_ITEMS_END, +/*N*/ aItemInfos, 0, bPersistenRefCounts ) +/*N*/ { +/*N*/ SetVersionMap( 1, 3999, 4015, aV1Map ); +/*N*/ SetVersionMap( 2, 3999, 4019, aV2Map ); +/*N*/ SetVersionMap( 3, 3997, 4020, aV3Map ); +/*N*/ SetVersionMap( 4, 3994, 4022, aV4Map ); +/*N*/ +/*N*/ DBG_ASSERT( EE_DLL(), "EditDLL?!" ); +/*N*/ SfxPoolItem** ppDefItems = EE_DLL()->GetGlobalData()->GetDefItems(); +/*N*/ SetDefaults( ppDefItems ); +/*N*/ } + +/*N*/ EditEngineItemPool::~EditEngineItemPool() +/*N*/ { +/*N*/ } + +/*N*/ SvStream& EditEngineItemPool::Store( SvStream& rStream ) const +/*N*/ { +/*N*/ // Bei einem 3.1-Export muess ein Hack eingebaut werden, da BUG im +/*N*/ // SfxItemSet::Load, aber nicht nachtraeglich in 3.1 fixbar. +/*N*/ +/*N*/ // Der eingestellte Range muss nach Store erhalten bleiben, weil dann +/*N*/ // erst die ItemSets gespeichert werden... +/*N*/ +/*N*/ long nVersion = rStream.GetVersion(); +/*N*/ BOOL b31Format = ( nVersion && ( nVersion <= SOFFICE_FILEFORMAT_31 ) ) +/*N*/ ? TRUE : FALSE; +/*N*/ +/*N*/ EditEngineItemPool* pThis = (EditEngineItemPool*)this; +/*N*/ if ( b31Format ) +/*N*/ pThis->SetStoringRange( 3997, 4022 ); +/*N*/ else +/*N*/ pThis->SetStoringRange( EE_ITEMS_START, EE_ITEMS_END ); +/*N*/ +/*N*/ return SfxItemPool::Store( rStream ); +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editdoc2.cxx b/binfilter/bf_svx/source/editeng/svx_editdoc2.cxx new file mode 100644 index 000000000000..ed31fed1d5e1 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editdoc2.cxx @@ -0,0 +1,345 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#include "eeitem.hxx" +#include "eeitemid.hxx" + + +#include <vcl/outdev.hxx> + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> + + +#include "kernitem.hxx" + +namespace binfilter { + +/*N*/ DBG_NAME( EE_ParaPortion ) + +/*N*/ SV_IMPL_VARARR( CharPosArray, sal_Int32 ); + +/* + +BOOL EditStyleSheet::HasStyleAsAnyParent( SfxStyleSheet& rStyle ) +{ + if ( GetParent() == rStyle.GetName() ) + return TRUE; + + if ( GetParent().Len() && ( GetParent() != GetName() ) ) + { + EditStyleSheet* pS = (EditStyleSheet*)GetPool().Find( GetParent(), rStyle.GetFamily() ); + if ( pS ) + return pS->HasStyleAsAnyParent( rStyle ); + } + return FALSE; +} + +*/ + +// ------------------------------------------------------------------------- +// class TextPortionList +// ------------------------------------------------------------------------- +/*N*/ TextPortionList::TextPortionList() +/*N*/ { +/*N*/ } + +/*N*/ TextPortionList::~TextPortionList() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +/*N*/ void TextPortionList::Reset() +/*N*/ { +/*N*/ for ( USHORT nPortion = 0; nPortion < Count(); nPortion++ ) +/*N*/ delete GetObject( nPortion ); +/*N*/ Remove( 0, Count() ); +/*N*/ } + +/*N*/ void TextPortionList::DeleteFromPortion( USHORT nDelFrom ) +/*N*/ { +/*N*/ DBG_ASSERT( ( nDelFrom < Count() ) || ( (nDelFrom == 0) && (Count() == 0) ), "DeleteFromPortion: Out of range" ); +/*N*/ for ( USHORT nP = nDelFrom; nP < Count(); nP++ ) +/*N*/ delete GetObject( nP ); +/*N*/ Remove( nDelFrom, Count()-nDelFrom ); +/*N*/ } + +/*N*/ USHORT TextPortionList::FindPortion( USHORT nCharPos, USHORT& nPortionStart, BOOL bPreferStartingPortion ) +/*N*/ { +/*N*/ // Bei nCharPos an Portion-Grenze wird die linke Portion gefunden +/*N*/ USHORT nTmpPos = 0; +/*N*/ for ( USHORT nPortion = 0; nPortion < Count(); nPortion++ ) +/*N*/ { +/*N*/ TextPortion* pPortion = GetObject( nPortion ); +/*N*/ nTmpPos += pPortion->GetLen(); +/*N*/ if ( nTmpPos >= nCharPos ) +/*N*/ { +/*N*/ // take this one if we don't prefer the starting portion, or if it's the last one +/*N*/ if ( ( nTmpPos != nCharPos ) || !bPreferStartingPortion || ( nPortion == Count() - 1 ) ) +/*N*/ { +/*N*/ nPortionStart = nTmpPos - pPortion->GetLen(); +/*N*/ return nPortion; +/*N*/ } +/*N*/ } +/*N*/ } +/*?*/ DBG_ERROR( "FindPortion: Nicht gefunden!" ); +/*?*/ return ( Count() - 1 ); +/*N*/ } + +/*N*/ ExtraPortionInfo::~ExtraPortionInfo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +// ------------------------------------------------------------------------- +// class ParaPortion +// ------------------------------------------------------------------------- +/*N*/ ParaPortion::ParaPortion( ContentNode* pN ) +/*N*/ { +/*N*/ DBG_CTOR( EE_ParaPortion, 0 ); +/*N*/ +/*N*/ pNode = pN; +/*N*/ bInvalid = TRUE; +/*N*/ bVisible = TRUE; +/*N*/ bSimple = FALSE; +/*N*/ bForceRepaint = FALSE; +/*N*/ nInvalidPosStart = 0; +/*N*/ nInvalidDiff = 0; +/*N*/ nHeight = 0; +/*N*/ nFirstLineOffset = 0; +/*N*/ nBulletX = 0; +/*N*/ } + +/*N*/ ParaPortion::~ParaPortion() +/*N*/ { +/*N*/ DBG_DTOR( EE_ParaPortion, 0 ); +/*N*/ } + +/*N*/ void ParaPortion::MarkInvalid( USHORT nStart, short nDiff ) +/*N*/ { +/*N*/ if ( bInvalid == FALSE ) +/*N*/ { +/*N*/ // nInvalidPosEnd = nStart; // ??? => CreateLines +/*N*/ nInvalidPosStart = ( nDiff >= 0 ) ? nStart : ( nStart + nDiff ); +/*N*/ nInvalidDiff = nDiff; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Einfaches hintereinander tippen +/*N*/ if ( ( nDiff > 0 ) && ( nInvalidDiff > 0 ) && +/*N*/ ( ( nInvalidPosStart+nInvalidDiff ) == nStart ) ) +/*N*/ { +/*N*/ nInvalidDiff += nDiff; +/*N*/ } +/*N*/ // Einfaches hintereinander loeschen +/*N*/ else if ( ( nDiff < 0 ) && ( nInvalidDiff < 0 ) && ( nInvalidPosStart == nStart ) ) +/*N*/ { +/*?*/ nInvalidPosStart += nDiff; +/*?*/ nInvalidDiff += nDiff; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // nInvalidPosEnd = pNode->Len(); +/*N*/ DBG_ASSERT( ( nDiff >= 0 ) || ( (nStart+nDiff) >= 0 ), "MarkInvalid: Diff out of Range" ); +/*N*/ nInvalidPosStart = Min( nInvalidPosStart, (USHORT) ( nDiff < 0 ? nStart+nDiff : nDiff ) ); +/*N*/ nInvalidDiff = 0; +/*N*/ bSimple = FALSE; +/*N*/ } +/*N*/ } +/*N*/ bInvalid = TRUE; +/*N*/ aScriptInfos.Remove( 0, aScriptInfos.Count() ); +/*N*/ aWritingDirectionInfos.Remove( 0, aWritingDirectionInfos.Count() ); +/*N*/ // aExtraCharInfos.Remove( 0, aExtraCharInfos.Count() ); +/*N*/ } + +/*N*/ void ParaPortion::MarkSelectionInvalid( USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ if ( bInvalid == FALSE ) +/*N*/ { +/*N*/ nInvalidPosStart = nStart; +/*N*/ // nInvalidPosEnd = nEnd; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nInvalidPosStart = Min( nInvalidPosStart, nStart ); +/*N*/ // nInvalidPosEnd = pNode->Len(); +/*N*/ } +/*N*/ nInvalidDiff = 0; +/*N*/ bInvalid = TRUE; +/*N*/ bSimple = FALSE; +/*N*/ aScriptInfos.Remove( 0, aScriptInfos.Count() ); +/*N*/ aWritingDirectionInfos.Remove( 0, aWritingDirectionInfos.Count() ); +/*N*/ // aExtraCharInfos.Remove( 0, aExtraCharInfos.Count() ); +/*N*/ } + +/*N*/ USHORT ParaPortion::GetLineNumber( USHORT nIndex ) +/*N*/ { +/*N*/ DBG_ASSERTWARNING( aLineList.Count(), "Leere ParaPortion in GetLine!" ); +/*N*/ DBG_ASSERT( bVisible, "Wozu GetLine() bei einem unsichtbaren Absatz?" ); +/*N*/ +/*N*/ for ( USHORT nLine = 0; nLine < aLineList.Count(); nLine++ ) +/*N*/ { +/*N*/ if ( aLineList[nLine]->IsIn( nIndex ) ) +/*N*/ return nLine; +/*N*/ } +/*N*/ +/*?*/ // Dann sollte es am Ende der letzten Zeile sein! +/*?*/ DBG_ASSERT( nIndex == aLineList[ aLineList.Count() - 1 ]->GetEnd(), "Index voll daneben!" ); +/*?*/ return (aLineList.Count()-1); +/*N*/ } + + +/*N*/ void ParaPortion::CorrectValuesBehindLastFormattedLine( USHORT nLastFormattedLine ) +/*N*/ { +/*N*/ USHORT nLines = aLineList.Count(); +/*N*/ DBG_ASSERT( nLines, "CorrectPortionNumbersFromLine: Leere Portion?" ); +/*N*/ if ( nLastFormattedLine < ( nLines - 1 ) ) +/*N*/ { +/*?*/ const EditLine* pLastFormatted = aLineList[ nLastFormattedLine ]; +/*?*/ const EditLine* pUnformatted = aLineList[ nLastFormattedLine+1 ]; +/*?*/ short nPortionDiff = pUnformatted->GetStartPortion() - pLastFormatted->GetEndPortion(); +/*?*/ short nTextDiff = pUnformatted->GetStart() - pLastFormatted->GetEnd(); +/*?*/ nTextDiff++; // LastFormatted->GetEnd() war incl. => 1 zuviel abgezogen! +/*?*/ +/*?*/ // Die erste unformatierte muss genau eine Portion hinter der letzten der +/*?*/ // formatierten beginnen: +/*?*/ // Wenn in der geaenderten Zeile eine Portion gesplittet wurde, +/*?*/ // kann nLastEnd > nNextStart sein! +/*?*/ short nPDiff = -( nPortionDiff-1 ); +/*?*/ short nTDiff = -( nTextDiff-1 ); +/*?*/ if ( nPDiff || nTDiff ) +/*?*/ { +/*?*/ for ( USHORT nL = nLastFormattedLine+1; nL < nLines; nL++ ) +/*?*/ { +/*?*/ EditLine* pLine = aLineList[ nL ]; +/*?*/ +/*?*/ pLine->GetStartPortion() += nPDiff; +/*?*/ pLine->GetEndPortion() += nPDiff; +/*?*/ +/*?*/ pLine->GetStart() += nTDiff; +/*?*/ pLine->GetEnd() += nTDiff; +/*?*/ +/*?*/ pLine->SetValid(); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ DBG_ASSERT( aLineList[ aLineList.Count()-1 ]->GetEnd() == pNode->Len(), "CorrectLines: Ende stimmt nicht!" ); +/*N*/ } + +// ------------------------------------------------------------------------- +// class ParaPortionList +// ------------------------------------------------------------------------- +/*N*/ ParaPortionList::ParaPortionList() +/*N*/ { +/*N*/ } + +/*N*/ ParaPortionList::~ParaPortionList() +/*N*/ { +/*N*/ Reset(); +/*N*/ } + +/*N*/ void ParaPortionList::Reset() +/*N*/ { +/*N*/ for ( USHORT nPortion = 0; nPortion < Count(); nPortion++ ) +/*N*/ delete GetObject( nPortion ); +/*N*/ Remove( 0, Count() ); +/*N*/ } + +/*N*/ long ParaPortionList::GetYOffset( ParaPortion* pPPortion ) +/*N*/ { +/*N*/ long nHeight = 0; +/*N*/ for ( USHORT nPortion = 0; nPortion < Count(); nPortion++ ) +/*N*/ { +/*N*/ ParaPortion* pTmpPortion = GetObject(nPortion); +/*N*/ if ( pTmpPortion == pPPortion ) +/*N*/ return nHeight; +/*?*/ nHeight += pTmpPortion->GetHeight(); +/*?*/ } +/*?*/ DBG_ERROR( "GetYOffset: Portion nicht gefunden" ); +/*?*/ return nHeight; +/*N*/ } + +/*N*/ USHORT ParaPortionList::FindParagraph( long nYOffset ) +/*N*/ { +/*N*/ long nY = 0; +/*N*/ for ( USHORT nPortion = 0; nPortion < Count(); nPortion++ ) +/*N*/ { +/*N*/ nY += GetObject(nPortion)->GetHeight(); // sollte auch bei !bVisible richtig sein! +/*N*/ if ( nY > nYOffset ) +/*N*/ return nPortion; +/*N*/ } +/*N*/ return 0xFFFF; // solte mal ueber EE_PARA_NOT_FOUND erreicht werden! +/*N*/ } + + + + + +/*N*/ void ConvertItem( SfxPoolItem& rPoolItem, MapUnit eSourceUnit, MapUnit eDestUnit ) +/*N*/ { +/*N*/ DBG_ASSERT( eSourceUnit != eDestUnit, "ConvertItem - Why?!" ); +/*N*/ +/*N*/ switch ( rPoolItem.Which() ) +/*N*/ { +/*N*/ case EE_PARA_LRSPACE: +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } +/*N*/ break; +/*N*/ case EE_PARA_ULSPACE: +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } +/*N*/ break; +/*N*/ case EE_PARA_SBL: +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } +/*N*/ break; +/*N*/ case EE_PARA_TABS: +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } +/*N*/ break; +/*N*/ case EE_CHAR_FONTHEIGHT: +/*N*/ case EE_CHAR_FONTHEIGHT_CJK: +/*N*/ case EE_CHAR_FONTHEIGHT_CTL: +/*N*/ {DBG_BF_ASSERT(0, "STRIP");//STRIP001 +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editeng.cxx b/binfilter/bf_svx/source/editeng/svx_editeng.cxx new file mode 100644 index 000000000000..451a23616f9a --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editeng.cxx @@ -0,0 +1,1357 @@ +/* -*- 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. + * + ************************************************************************/ + + +// #define _SOLAR__PRIVATE 1 +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define USE_SVXFONT + +#define _SVSTDARR_USHORTS +#include <bf_svtools/svstdarr.hxx> + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> +#include <editview.hxx> +#include <eerdll2.hxx> +#include <eerdll.hxx> +#include <editeng.hrc> + + + +#include "itemdata.hxx" + + + +#include <flditem.hxx> + +#include "lrspitem.hxx" + + +#include <numitem.hxx> +#include <bulitem.hxx> + + + + + +#if OSL_DEBUG_LEVEL > 1 +#endif +namespace binfilter { + +// Spaeter -> TOOLS\STRING.H (fuer Grep: WS_TARGET) + +//using namespace ::rtl; +//using namespace ::utl; +using namespace ::com::sun::star; +//using namespace ::com::sun::star::util; +using namespace ::com::sun::star::uno; +//using namespace ::com::sun::star::lang; +//using namespace ::com::sun::star::beans; +//using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::linguistic2; + + + +/*N*/ DBG_NAME( EditEngine ) +/*N*/ DBG_NAMEEX( EditView )//STRIP008 ; + +#if (OSL_DEBUG_LEVEL > 1) || defined ( DBG_UTIL ) +/*N*/ static sal_Bool bDebugPaint = sal_False; +#endif + +SV_IMPL_VARARR( EECharAttribArray, EECharAttrib ); + + +// ---------------------------------------------------------------------- +// EditEngine +// ---------------------------------------------------------------------- +/*N*/ EditEngine::EditEngine( SfxItemPool* pItemPool ) +/*N*/ { +/*N*/ DBG_CTOR( EditEngine, 0 ); +/*N*/ pImpEditEngine = new ImpEditEngine( this, pItemPool ); +/*N*/ } + +/*N*/ EditEngine::~EditEngine() +/*N*/ { +/*N*/ DBG_DTOR( EditEngine, 0 ); +/*N*/ delete pImpEditEngine; +/*N*/ } + +/*N*/ void EditEngine::EnableUndo( sal_Bool bEnable ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->EnableUndo( bEnable ); +/*N*/ } + +/*N*/ sal_Bool EditEngine::IsUndoEnabled() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->IsUndoEnabled(); +/*N*/ } + +/*N*/ sal_Bool EditEngine::IsInUndo() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->IsInUndo(); +/*N*/ } + +#ifndef SVX_LIGHT +/*N*/ SfxUndoManager& EditEngine::GetUndoManager() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetUndoManager(); +/*N*/ } +#endif + +/*N*/ void EditEngine::UndoActionStart( sal_uInt16 nId ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Aufruf von UndoActionStart im Undomodus!" ); +/*N*/ if ( !pImpEditEngine->IsInUndo() ) +/*N*/ pImpEditEngine->UndoActionStart( nId ); +/*N*/ } + +/*N*/ void EditEngine::UndoActionEnd( sal_uInt16 nId ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ DBG_ASSERT( !pImpEditEngine->IsInUndo(), "Aufruf von UndoActionEnd im Undomodus!" ); +/*N*/ if ( !pImpEditEngine->IsInUndo() ) +/*N*/ pImpEditEngine->UndoActionEnd( nId ); +/*N*/ } + +/*N*/ void EditEngine::SetRefDevice( OutputDevice* pRefDev ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetRefDevice( pRefDev ); +/*N*/ } + +/*N*/ OutputDevice* EditEngine::GetRefDevice() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetRefDevice(); +/*N*/ } + +/*N*/ void EditEngine::SetRefMapMode( const MapMode& rMapMode ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetRefMapMode( rMapMode ); +/*N*/ } + +/*N*/ MapMode EditEngine::GetRefMapMode() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetRefMapMode(); +/*N*/ } + +/*N*/ void EditEngine::SetBackgroundColor( const Color& rColor ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetBackgroundColor( rColor ); +/*N*/ } + + +/*N*/ Color EditEngine::GetAutoColor() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetAutoColor(); +/*N*/ } + +/*N*/ void EditEngine::EnableAutoColor( BOOL b ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->EnableAutoColor( b ); +/*N*/ } + + + +/*N*/ BOOL EditEngine::IsForceAutoColor() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->IsForceAutoColor(); +/*N*/ } + +/*N*/ const SfxItemSet& EditEngine::GetEmptyItemSet() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetEmptyItemSet(); +/*N*/ } + + +/*N*/ EditView* EditEngine::RemoveView( EditView* pView ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ +/*N*/ pView->HideCursor(); +/*N*/ EditView* pRemoved = 0; +/*N*/ sal_uInt16 nPos = pImpEditEngine->GetEditViews().GetPos( pView ); +/*N*/ DBG_ASSERT( nPos != USHRT_MAX, "RemoveView mit ungueltigem Index" ); +/*N*/ if ( nPos != USHRT_MAX ) +/*N*/ { +/*N*/ pRemoved = pImpEditEngine->GetEditViews().GetObject( nPos ); +/*N*/ pImpEditEngine->GetEditViews().Remove( nPos ); +/*N*/ if ( pImpEditEngine->GetActiveView() == pView ) +/*N*/ { +/*N*/ pImpEditEngine->SetActiveView( 0 ); +/*N*/ pImpEditEngine->GetSelEngine().SetCurView( 0 ); +/*N*/ } +/*N*/ } +/*N*/ return pRemoved; +/*N*/ } + + + + +/*N*/ sal_Bool EditEngine::HasView( EditView* pView ) const +/*N*/ { +/*N*/ return pImpEditEngine->GetEditViews().GetPos( pView ) != USHRT_MAX; +/*N*/ } + + + +/*N*/ void EditEngine::SetDefTab( sal_uInt16 nDefTab ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->GetEditDoc().SetDefTab( nDefTab ); +/*N*/ if ( pImpEditEngine->IsFormatted() ) +/*N*/ { +/*N*/ pImpEditEngine->FormatFullDoc(); +/*N*/ pImpEditEngine->UpdateViews( (EditView*) 0 ); +/*N*/ } +/*N*/ } + + +/*N*/ void EditEngine::SetPaperSize( const Size& rNewSize ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ Size aOldSize( pImpEditEngine->GetPaperSize() ); +/*N*/ pImpEditEngine->SetValidPaperSize( rNewSize ); +/*N*/ Size aNewSize( pImpEditEngine->GetPaperSize() ); +/*N*/ +/*N*/ sal_Bool bAutoPageSize = pImpEditEngine->GetStatus().AutoPageSize(); +/*N*/ if ( bAutoPageSize || ( aNewSize.Width() != aOldSize.Width() ) ) +/*N*/ { +/*N*/ for ( sal_uInt16 nView = 0; nView < pImpEditEngine->aEditViews.Count(); nView++ ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditView* pView = pImpEditEngine->aEditViews[nView]; +/*N*/ } +/*N*/ +/*N*/ if ( bAutoPageSize || pImpEditEngine->IsFormatted() ) +/*N*/ { +/*N*/ // Aendern der Breite hat bei AutoPageSize keine Wirkung, da durch +/*N*/ // Textbreite bestimmt. +/*N*/ // Optimierung erst nach Vobis-Auslieferung aktivieren... +/*N*/ // if ( !bAutoPageSize ) +/*N*/ pImpEditEngine->FormatFullDoc(); +/*N*/ // else +/*N*/ // { +/*N*/ // pImpEditEngine->FormatDoc(); // PageSize, falls Aenderung +/*N*/ // pImpEditEngine->CheckAutoPageSize(); // Falls nichts formatiert wurde +/*N*/ // } +/*N*/ +/*N*/ pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() ); +/*N*/ +/*N*/ if ( pImpEditEngine->GetUpdateMode() && pImpEditEngine->GetActiveView() ) +/*?*/ pImpEditEngine->pActiveView->ShowCursor( sal_False, sal_False ); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ const Size& EditEngine::GetPaperSize() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetPaperSize(); +/*N*/ } + +/*N*/ void EditEngine::SetVertical( BOOL bVertical ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetVertical( bVertical ); +/*N*/ } + +/*N*/ BOOL EditEngine::IsVertical() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->IsVertical(); +/*N*/ } + + + +/*N*/ USHORT EditEngine::GetScriptType( const ESelection& rSelection ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ EditSelection aSel( pImpEditEngine->CreateSel( rSelection ) ); +/*N*/ return pImpEditEngine->GetScriptType( aSel ); +/*N*/ } + +/*N*/ LanguageType EditEngine::GetLanguage( USHORT nPara, USHORT nPos ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "GetLanguage - nPara is invalid!" ); +/*N*/ return pNode ? pImpEditEngine->GetLanguage( EditPaM( pNode, nPos ) ) : LANGUAGE_DONTKNOW; +/*N*/ } + + + +/*N*/ void EditEngine::SetAsianCompressionMode( USHORT n ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ pImpEditEngine->SetAsianCompressionMode( n ); +/*N*/ } + + +/*N*/ void EditEngine::SetKernAsianPunctuation( BOOL b ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ pImpEditEngine->SetKernAsianPunctuation( b ); +/*N*/ } + + + + +/*N*/ void EditEngine::ClearPolygon() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetTextRanger( 0 ); +/*N*/ } + + + +/*N*/ void EditEngine::SetMinAutoPaperSize( const Size& rSz ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetMinAutoPaperSize( rSz ); +/*N*/ } + + +/*N*/ void EditEngine::SetMaxAutoPaperSize( const Size& rSz ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetMaxAutoPaperSize( rSz ); +/*N*/ } + +/*N*/ XubString EditEngine::GetText( LineEnd eEnd ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetEditDoc().GetText( eEnd ); +/*N*/ } + +/*N*/ XubString EditEngine::GetText( const ESelection& rESelection, const LineEnd eEnd ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ EditSelection aSel( pImpEditEngine->CreateSel( rESelection ) ); +/*N*/ return pImpEditEngine->GetSelected( aSel, eEnd ); +/*N*/ } + +/*N*/ sal_uInt16 EditEngine::GetParagraphCount() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->aEditDoc.Count(); +/*N*/ } + +/*N*/ sal_uInt16 EditEngine::GetLineCount( sal_uInt16 nParagraph ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetLineCount( nParagraph ); +/*N*/ } + +/*N*/ sal_uInt16 EditEngine::GetLineLen( sal_uInt16 nParagraph, sal_uInt16 nLine ) const +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return 0; //STRIP001 +/*N*/ } + +/*?*/ sal_uInt32 EditEngine::GetLineHeight( sal_uInt16 nParagraph, sal_uInt16 nLine ) +/*?*/ {{DBG_BF_ASSERT(0, "STRIP");} return 0;//STRIP001 +/*?*/ } + +/*N*/ sal_uInt16 EditEngine::GetFirstLineOffset( sal_uInt16 nParagraph ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*?*/ pImpEditEngine->FormatDoc(); +/*N*/ ParaPortion* pPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nParagraph ); +/*N*/ return ( pPortion ? pPortion->GetFirstLineOffset() : 0 ); +/*N*/ } + +/*N*/ sal_uInt32 EditEngine::GetTextHeight( sal_uInt16 nParagraph ) const +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return 0; //STRIP001 +/*N*/ } + + +/*N*/ ESelection EditEngine::GetWord( const ESelection& rSelection, USHORT nWordType ) const +/*N*/ { +/*N*/ // ImpEditEngine-Iteration-Methods should be const! +/*N*/ EditEngine* pE = (EditEngine*)this; +/*N*/ +/*N*/ EditSelection aSel( pE->pImpEditEngine->CreateSel( rSelection ) ); +/*N*/ aSel = pE->pImpEditEngine->SelectWord( aSel, nWordType ); +/*N*/ return pE->pImpEditEngine->CreateESel( aSel ); +/*N*/ } + +/*N*/ sal_uInt32 EditEngine::GetTextHeight() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*?*/ pImpEditEngine->FormatDoc(); +/*N*/ +/*N*/ sal_uInt32 nHeight = !IsVertical() ? pImpEditEngine->GetTextHeight() : pImpEditEngine->CalcTextWidth( TRUE ); +/*N*/ return nHeight; +/*N*/ } + +/*N*/ sal_uInt32 EditEngine::CalcTextWidth() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*?*/ pImpEditEngine->FormatDoc(); +/*N*/ +/*N*/ sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( TRUE ) : pImpEditEngine->GetTextHeight(); +/*N*/ return nWidth; +/*N*/ } + +/*N*/ void EditEngine::SetUpdateMode( sal_Bool bUpdate ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetUpdateMode( bUpdate ); +/*N*/ if ( pImpEditEngine->pActiveView ) +/*?*/ pImpEditEngine->pActiveView->ShowCursor( sal_False, sal_False ); +/*N*/ } + +/*N*/ sal_Bool EditEngine::GetUpdateMode() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetUpdateMode(); +/*N*/ } + +/*N*/ void EditEngine::Clear() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->Clear(); +/*N*/ } + +/*N*/ void EditEngine::SetText( const XubString& rText ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetText( rText ); +/*N*/ if ( rText.Len() ) +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ } + +/*N*/ EditTextObject* EditEngine::CreateTextObject() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->CreateTextObject(); +/*N*/ } + + +/*N*/ void EditEngine::SetText( const EditTextObject& rTextObject ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->EnterBlockNotifications(); +/*N*/ pImpEditEngine->SetText( rTextObject ); +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ pImpEditEngine->LeaveBlockNotifications(); +/*N*/ } + + + +/*N*/ void EditEngine::SetNotifyHdl( const Link& rLink ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetNotifyHdl( rLink ); +/*N*/ } + +/*N*/ Link EditEngine::GetNotifyHdl() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetNotifyHdl(); +/*N*/ } + +/*N*/ void EditEngine::SetBeginMovingParagraphsHdl( const Link& rLink ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->aBeginMovingParagraphsHdl = rLink; +/*N*/ } + +/*N*/ void EditEngine::SetEndMovingParagraphsHdl( const Link& rLink ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->aEndMovingParagraphsHdl = rLink; +/*N*/ } + +/*N*/ void EditEngine::SetBeginPasteOrDropHdl( const Link& rLink ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->aBeginPasteOrDropHdl = rLink; +/*N*/ } + +/*N*/ void EditEngine::SetEndPasteOrDropHdl( const Link& rLink ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->aEndPasteOrDropHdl = rLink; +/*N*/ } + +/*N*/ EditTextObject* EditEngine::CreateTextObject( sal_uInt16 nPara, sal_uInt16 nParas ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ DBG_ASSERT( nPara < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Startpara out of Range" ); +/*N*/ DBG_ASSERT( nPara+nParas-1 < pImpEditEngine->GetEditDoc().Count(), "CreateTextObject: Endpara out of Range" ); +/*N*/ +/*N*/ ContentNode* pStartNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); +/*N*/ ContentNode* pEndNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara+nParas-1 ); +/*N*/ DBG_ASSERT( pStartNode, "Start-Absatz existiert nicht: CreateTextObject" ); +/*N*/ DBG_ASSERT( pEndNode, "End-Absatz existiert nicht: CreateTextObject" ); +/*N*/ +/*N*/ if ( pStartNode && pEndNode ) +/*N*/ { +/*N*/ EditSelection aTmpSel; +/*N*/ aTmpSel.Min() = EditPaM( pStartNode, 0 ); +/*N*/ aTmpSel.Max() = EditPaM( pEndNode, pEndNode->Len() ); +/*N*/ return pImpEditEngine->CreateTextObject( aTmpSel ); +/*N*/ } +/*N*/ return 0; +/*N*/ } + + +/*N*/ sal_uInt16 EditEngine::GetTextLen( sal_uInt16 nPara ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "Absatz nicht gefunden: GetTextLen" ); +/*N*/ if ( pNode ) +/*N*/ return pNode->Len(); +/*N*/ return 0; +/*N*/ } + +/*N*/ XubString EditEngine::GetText( sal_uInt16 nPara ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ XubString aStr; +/*N*/ if ( nPara < pImpEditEngine->GetEditDoc().Count() ) +/*N*/ aStr = pImpEditEngine->GetEditDoc().GetParaAsString( nPara ); +/*N*/ return aStr; +/*N*/ } + +/*N*/ sal_Bool EditEngine::IsModified() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->IsModified(); +/*N*/ } + + + + +/*N*/ void EditEngine::InsertParagraph( sal_uInt16 nPara, const XubString& rTxt ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ if ( nPara > GetParagraphCount() ) +/*N*/ { +/*?*/ DBG_ASSERTWARNING( nPara == USHRT_MAX, "AbsatzNr zu Gro? aber nicht LIST_APPEND! " ); +/*?*/ nPara = GetParagraphCount(); +/*N*/ } +/*N*/ +/*N*/ pImpEditEngine->UndoActionStart( EDITUNDO_INSERT ); +/*N*/ EditPaM aPaM( pImpEditEngine->InsertParagraph( nPara ) ); +/*N*/ // Bei einem InsertParagraph von aussen sollen keine Harten +/*N*/ // Attribute uebernommen werden ! +/*N*/ pImpEditEngine->RemoveCharAttribs( nPara ); +/*N*/ pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT ); +/*N*/ pImpEditEngine->ImpInsertText( EditSelection( aPaM, aPaM ), rTxt ); +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ } + + +/*N*/ void EditEngine::SetText( sal_uInt16 nPara, const XubString& rTxt ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ EditSelection* pSel = pImpEditEngine->SelectParagraph( nPara ); +/*N*/ if ( pSel ) +/*N*/ { +/*N*/ pImpEditEngine->UndoActionStart( EDITUNDO_INSERT ); +/*N*/ pImpEditEngine->ImpInsertText( *pSel, rTxt ); +/*N*/ pImpEditEngine->UndoActionEnd( EDITUNDO_INSERT ); +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ delete pSel; +/*N*/ } +/*N*/ } + +/*N*/ void EditEngine::SetParaAttribs( sal_uInt16 nPara, const SfxItemSet& rSet ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ // Keine Undoklammerung noetig. +/*N*/ pImpEditEngine->SetParaAttribs( nPara, rSet ); +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ } + +/*N*/ const SfxItemSet& EditEngine::GetParaAttribs( sal_uInt16 nPara ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetParaAttribs( nPara ); +/*N*/ } + +/*N*/ sal_Bool EditEngine::HasParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->HasParaAttrib( nPara, nWhich ); +/*N*/ } + +/*N*/ const SfxPoolItem& EditEngine::GetParaAttrib( sal_uInt16 nPara, sal_uInt16 nWhich ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetParaAttrib( nPara, nWhich ); +/*N*/ } + +/*N*/ void EditEngine::GetCharAttribs( sal_uInt16 nPara, EECharAttribArray& rLst ) const +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ SfxItemSet EditEngine::GetAttribs( const ESelection& rSel, BOOL bOnlyHardAttrib ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ return pImpEditEngine->GetAttribs( aSel, bOnlyHardAttrib ); +/*N*/ } + +/*N*/ SfxItemSet EditEngine::GetAttribs( USHORT nPara, USHORT nStart, USHORT nEnd, sal_uInt8 nFlags ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetAttribs( nPara, nStart, nEnd, nFlags ); +/*N*/ } + + +// MT: Can be removed after 6.x? + + +/*N*/ void EditEngine::StripPortions() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ VirtualDevice aTmpDev; +/*N*/ Rectangle aBigRec( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) ); +/*N*/ if ( IsVertical() ) +/*N*/ { +/*?*/ aBigRec.Right() = 0; +/*?*/ aBigRec.Left() = -0x7FFFFFFF; +/*N*/ } +/*N*/ pImpEditEngine->Paint( &aTmpDev, aBigRec, Point(), sal_True ); +/*N*/ } + +/*N*/ void EditEngine::GetPortions( sal_uInt16 nPara, SvUShorts& rList ) +/*N*/ { +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*N*/ pImpEditEngine->FormatFullDoc(); +/*N*/ +/*N*/ ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( pParaPortion ) +/*N*/ { +/*N*/ sal_uInt16 nEnd = 0; +/*N*/ sal_uInt16 nTextPortions = pParaPortion->GetTextPortions().Count(); +/*N*/ for ( sal_uInt16 n = 0; n < nTextPortions; n++ ) +/*N*/ { +/*N*/ nEnd += pParaPortion->GetTextPortions()[n]->GetLen(); +/*N*/ rList.Insert( nEnd, rList.Count() ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ sal_Bool EditEngine::IsFlatMode() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return !( pImpEditEngine->aStatus.UseCharAttribs() ); +/*N*/ } + +/*N*/ void EditEngine::SetControlWord( sal_uInt32 nWord ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( nWord != pImpEditEngine->aStatus.GetControlWord() ) +/*N*/ { +/*N*/ sal_uInt32 nPrev = pImpEditEngine->aStatus.GetControlWord(); +/*N*/ pImpEditEngine->aStatus.GetControlWord() = nWord; +/*N*/ +/*N*/ sal_uInt32 nChanges = nPrev ^ nWord; +/*N*/ if ( pImpEditEngine->IsFormatted() ) +/*N*/ { +/*N*/ // ggf. neu formatieren: +/*N*/ if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) || +/*N*/ ( nChanges & EE_CNTRL_USEPARAATTRIBS ) || +/*N*/ ( nChanges & EE_CNTRL_ONECHARPERLINE ) || +/*N*/ ( nChanges & EE_CNTRL_STRETCHING ) || +/*N*/ ( nChanges & EE_CNTRL_OUTLINER ) || +/*N*/ ( nChanges & EE_CNTRL_NOCOLORS ) || +/*N*/ ( nChanges & EE_CNTRL_OUTLINER2 ) ) +/*N*/ { +/*N*/ if ( ( nChanges & EE_CNTRL_USECHARATTRIBS ) || +/*N*/ ( nChanges & EE_CNTRL_USEPARAATTRIBS ) ) +/*N*/ { +/*?*/ sal_Bool bUseCharAttribs = ( nWord & EE_CNTRL_USECHARATTRIBS ) ? sal_True : sal_False; +/*?*/ pImpEditEngine->GetEditDoc().CreateDefFont( bUseCharAttribs ); +/*N*/ } +/*N*/ +/*N*/ pImpEditEngine->FormatFullDoc(); +/*N*/ pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ sal_uInt32 EditEngine::GetControlWord() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->aStatus.GetControlWord(); +/*N*/ } + + +/*N*/ Point EditEngine::GetDocPos( const Point& rPaperPos ) const +/*N*/ { +/*N*/ Point aDocPos( rPaperPos ); +/*N*/ if ( IsVertical() ) +/*N*/ { +/*?*/ aDocPos.X() = rPaperPos.Y(); +/*?*/ aDocPos.Y() = GetPaperSize().Width() - rPaperPos.X(); +/*N*/ } +/*N*/ return aDocPos; +/*N*/ } + +/*N*/ Point EditEngine::GetDocPosTopLeft( sal_uInt16 nParagraph ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ ParaPortion* pPPortion = pImpEditEngine->GetParaPortions().SaveGetObject( nParagraph ); +/*N*/ DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetWindowPosTopLeft" ); +/*N*/ Point aPoint; +/*N*/ if ( pPPortion ) +/*N*/ { +/*N*/ // Falls jemand mit einer leeren Engine ein GetLineHeight() macht. +/*N*/ DBG_ASSERT( pImpEditEngine->IsFormatted() || !pImpEditEngine->IsFormatting(), "GetDocPosTopLeft: Doc not formatted - unable to format!" ); +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*?*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ if ( pPPortion->GetLines().Count() ) +/*N*/ { +/*N*/ // So richtiger, falls grosses Bullet. +/*N*/ EditLine* pFirstLine = pPPortion->GetLines()[0]; +/*N*/ aPoint.X() = pFirstLine->GetStartPosX(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ const SvxLRSpaceItem& rLRItem = pImpEditEngine->GetLRSpaceItem( pPPortion->GetNode() ); +/*?*/ aPoint.X() = pImpEditEngine->GetXValue( (short)(rLRItem.GetTxtLeft() + rLRItem.GetTxtFirstLineOfst()) ); +/*N*/ } +/*N*/ aPoint.Y() = pImpEditEngine->GetParaPortions().GetYOffset( pPPortion ); +/*N*/ } +/*N*/ return aPoint; +/*N*/ } + + +/*N*/ sal_Bool EditEngine::IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*?*/ pImpEditEngine->FormatDoc(); +/*N*/ +/*N*/ sal_Bool bTextPos = sal_False; +/*N*/ // #90780# take unrotated positions for calculation here +/*N*/ Point aDocPos = GetDocPos( rPaperPos ); +/*N*/ +/*N*/ if ( ( aDocPos.Y() > 0 ) && ( aDocPos.Y() < (long)pImpEditEngine->GetTextHeight() ) ) +/*N*/ { +/*N*/ EditPaM aPaM = pImpEditEngine->GetPaM( aDocPos, sal_False ); +/*N*/ if ( aPaM.GetNode() ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = pImpEditEngine->FindParaPortion( aPaM.GetNode() ); +/*N*/ DBG_ASSERT( pParaPortion, "ParaPortion?" ); +/*N*/ +/*N*/ sal_uInt16 nLine = pParaPortion->GetLineNumber( aPaM.GetIndex() ); +/*N*/ EditLine* pLine = pParaPortion->GetLines().GetObject( nLine ); +/*N*/ Range aLineXPosStartEnd = pImpEditEngine->GetLineXPosStartEnd( pParaPortion, pLine ); +/*N*/ if ( ( aDocPos.X() >= aLineXPosStartEnd.Min() - nBorder ) && +/*N*/ ( aDocPos.X() <= aLineXPosStartEnd.Max() + nBorder ) ) +/*N*/ { +/*N*/ bTextPos = sal_True; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bTextPos; +/*N*/ } + +/*N*/ void EditEngine::SetEditTextObjectPool( SfxItemPool* pPool ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetEditTextObjectPool( pPool ); +/*N*/ } + +/*N*/ SfxItemPool* EditEngine::GetEditTextObjectPool() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetEditTextObjectPool(); +/*N*/ } + +/*N*/ void EditEngine::QuickSetAttribs( const SfxItemSet& rSet, const ESelection& rSel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ +/*N*/ pImpEditEngine->SetAttribs( aSel, rSet ); +/*N*/ } + + +/*N*/ void EditEngine::QuickInsertText( const XubString& rText, const ESelection& rSel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ +/*N*/ pImpEditEngine->ImpInsertText( aSel, rText ); +/*N*/ } + +/*N*/ void EditEngine::QuickDelete( const ESelection& rSel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ +/*N*/ pImpEditEngine->ImpDeleteSelection( aSel ); +/*N*/ } + + +/*N*/ void EditEngine::QuickInsertLineBreak( const ESelection& rSel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ +/*N*/ pImpEditEngine->InsertLineBreak( aSel ); +/*N*/ } + +/*N*/ void EditEngine::QuickInsertField( const SvxFieldItem& rFld, const ESelection& rSel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ EditSelection aSel( pImpEditEngine-> +/*N*/ ConvertSelection( rSel.nStartPara, rSel.nStartPos, rSel.nEndPara, rSel.nEndPos ) ); +/*N*/ +/*N*/ pImpEditEngine->ImpInsertFeature( aSel, rFld ); +/*N*/ } + +/*N*/ void EditEngine::QuickFormatDoc( sal_Bool bFull ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ if ( bFull ) +/*N*/ pImpEditEngine->FormatFullDoc(); +/*N*/ else +/*N*/ pImpEditEngine->FormatDoc(); +/*N*/ pImpEditEngine->UpdateViews( pImpEditEngine->GetActiveView() ); +/*N*/ } + +/*N*/ void EditEngine::QuickRemoveCharAttribs( sal_uInt16 nPara, sal_uInt16 nWhich ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->RemoveCharAttribs( nPara, nWhich ); +/*N*/ } + +/*N*/ void EditEngine::SetStyleSheet( sal_uInt16 nPara, SfxStyleSheet* pStyle ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetStyleSheet( nPara, pStyle ); +/*N*/ } + +/*N*/ SfxStyleSheet* EditEngine::GetStyleSheet( sal_uInt16 nPara ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetStyleSheet( nPara ); +/*N*/ } + +/*N*/ void EditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetStyleSheetPool( pSPool ); +/*N*/ } + +/*N*/ SfxStyleSheetPool* EditEngine::GetStyleSheetPool() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->GetStyleSheetPool(); +/*N*/ } + +/*N*/ void EditEngine::SetWordDelimiters( const XubString& rDelimiters ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->aWordDelimiters = rDelimiters; +/*N*/ if ( pImpEditEngine->aWordDelimiters.Search( CH_FEATURE ) == STRING_NOTFOUND ) +/*N*/ pImpEditEngine->aWordDelimiters.Insert( CH_FEATURE ); +/*N*/ } + +/*N*/ XubString EditEngine::GetWordDelimiters() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return pImpEditEngine->aWordDelimiters; +/*N*/ } + + + + + + + +/*N*/ void EditEngine::EraseVirtualDevice() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->EraseVirtualDevice(); +/*N*/ } + +/*N*/ void EditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetForbiddenCharsTable( xForbiddenChars ); +/*N*/ } + + + +/*N*/ void EditEngine::SetDefaultLanguage( LanguageType eLang ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetDefaultLanguage( eLang ); +/*N*/ } + + + + + + +/*N*/ void EditEngine::SetGlobalCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ pImpEditEngine->SetCharStretching( nX, nY ); +/*N*/ } + + +/*N*/ sal_Bool EditEngine::ShouldCreateBigTextObject() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ sal_uInt16 nTextPortions = 0; +/*N*/ sal_uInt16 nParas = pImpEditEngine->GetEditDoc().Count(); +/*N*/ for ( sal_uInt16 nPara = 0; nPara < nParas; nPara++ ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara]; +/*N*/ nTextPortions += pParaPortion->GetTextPortions().Count(); +/*N*/ } +/*N*/ return ( nTextPortions >= pImpEditEngine->GetBigTextObjectStart() ) ? sal_True : sal_False; +/*N*/ } + +/*N*/ USHORT EditEngine::GetFieldCount( USHORT nPara ) const +/*N*/ { +/*N*/ USHORT nFields = 0; +/*N*/ ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); +/*N*/ if ( pNode ) +/*N*/ { +/*N*/ const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ for ( sal_uInt16 nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttrs[nAttr]; +/*N*/ if ( pAttr->Which() == EE_FEATURE_FIELD ) +/*N*/ nFields++; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return nFields; +/*N*/ } + +/*N*/ EFieldInfo EditEngine::GetFieldInfo( USHORT nPara, USHORT nField ) const +/*N*/ { +/*N*/ ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( nPara ); +/*N*/ if ( pNode ) +/*N*/ { +/*N*/ USHORT nCurrentField = 0; +/*N*/ const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ for ( sal_uInt16 nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttrs[nAttr]; +/*N*/ if ( pAttr->Which() == EE_FEATURE_FIELD ) +/*N*/ { +/*N*/ if ( nCurrentField == nField ) +/*N*/ { +/*N*/ EFieldInfo aInfo( *(const SvxFieldItem*)pAttr->GetItem(), nPara, pAttr->GetStart() ); +/*N*/ aInfo.aCurrentText = ((EditCharAttribField*)pAttr)->GetFieldValue(); +/*N*/ return aInfo; +/*N*/ } +/*N*/ +/*N*/ nCurrentField++; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return EFieldInfo(); +/*N*/ } + + +/*N*/ sal_Bool EditEngine::UpdateFields() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ sal_Bool bChanges = pImpEditEngine->UpdateFields(); +/*N*/ if ( bChanges ) +/*N*/ pImpEditEngine->FormatAndUpdate(); +/*N*/ return bChanges; +/*N*/ } + +/*N*/ USHORT EditEngine::FindParagraph( long nDocPosY ) +/*N*/ { +/*N*/ return pImpEditEngine->GetParaPortions().FindParagraph( nDocPosY ); +/*N*/ } + +/*N*/ EPosition EditEngine::FindDocPosition( const Point& rDocPos ) const +/*N*/ { +/*N*/ EPosition aPos; +/*N*/ // From the point of the API, this is const.... +/*N*/ EditPaM aPaM = ((EditEngine*)this)->pImpEditEngine->GetPaM( rDocPos, FALSE ); +/*N*/ if ( aPaM.GetNode() ) +/*N*/ { +/*N*/ aPos.nPara = pImpEditEngine->aEditDoc.GetPos( aPaM.GetNode() ); +/*N*/ aPos.nIndex = aPaM.GetIndex(); +/*N*/ } +/*N*/ return aPos; +/*N*/ } + +/*N*/ Rectangle EditEngine::GetCharacterBounds( const EPosition& rPos ) const +/*N*/ { +/*N*/ Rectangle aBounds; +/*N*/ ContentNode* pNode = pImpEditEngine->GetEditDoc().SaveGetObject( rPos.nPara ); +/*N*/ +/*N*/ // #109151# Check against index, not paragraph +/*N*/ if ( pNode && ( rPos.nIndex < pNode->Len() ) ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } +/*N*/ return aBounds; +/*N*/ } + +/*N*/ ParagraphInfos EditEngine::GetParagraphInfos( sal_uInt16 nPara ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ // Funktioniert nur, wenn nicht bereits in der Formatierung... +/*N*/ if ( !pImpEditEngine->IsFormatted() ) +/*N*/ pImpEditEngine->FormatDoc(); +/*N*/ +/*N*/ ParagraphInfos aInfos; +/*N*/ aInfos.bValid = pImpEditEngine->IsFormatted(); +/*N*/ if ( pImpEditEngine->IsFormatted() ) +/*N*/ { +/*?*/ ParaPortion* pParaPortion = pImpEditEngine->GetParaPortions()[nPara]; +/*?*/ EditLine* pLine = pParaPortion ? pParaPortion->GetLines().GetObject( 0 ) : NULL; +/*?*/ DBG_ASSERT( pParaPortion && pLine, "GetParagraphInfos - Paragraph out of range" ); +/*?*/ if ( pParaPortion && pLine ) +/*?*/ { +/*?*/ aInfos.nParaHeight = (USHORT)pParaPortion->GetHeight(); +/*?*/ aInfos.nLines = pParaPortion->GetLines().Count(); +/*?*/ aInfos.nFirstLineStartX = pLine->GetStartPosX(); +/*?*/ aInfos.nFirstLineOffset = pParaPortion->GetFirstLineOffset(); +/*?*/ aInfos.nFirstLineHeight = pLine->GetHeight(); +/*?*/ aInfos.nFirstLineTextHeight = pLine->GetTxtHeight(); +/*?*/ aInfos.nFirstLineMaxAscent = pLine->GetMaxAscent(); +/*?*/ } +/*N*/ } +/*N*/ return aInfos; +/*N*/ } + + +// ===================================================================== +// ====================== Virtuelle Methoden ======================= +// ===================================================================== +/*N*/ void __EXPORT EditEngine::DrawingText( const Point&, const XubString&, USHORT nTextStart, USHORT nTextLen, const sal_Int32*, const SvxFont&, sal_uInt16 nPara, sal_uInt16 nIndex, BYTE nRightToLeft ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ } + +/*N*/ void __EXPORT EditEngine::PaintingFirstLine( sal_uInt16, const Point&, long, const Point&, short, OutputDevice* ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ } + +/*N*/ void __EXPORT EditEngine::ParagraphInserted( sal_uInt16 nPara ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( GetNotifyHdl().IsSet() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EENotify aNotify( EE_NOTIFY_PARAGRAPHINSERTED ); +/*N*/ } +/*N*/ } + +/*N*/ void __EXPORT EditEngine::ParagraphDeleted( sal_uInt16 nPara ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( GetNotifyHdl().IsSet() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EENotify aNotify( EE_NOTIFY_PARAGRAPHREMOVED ); +/*N*/ } +/*N*/ } + +/*N*/ sal_Bool __EXPORT EditEngine::FormattingParagraph( sal_uInt16 ) +/*N*/ { +/*N*/ // return sal_True, wenn die Attribute geaendert wurden... +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return sal_False; +/*N*/ } + +/*N*/ void __EXPORT EditEngine::ParaAttribsChanged( sal_uInt16 /* nParagraph */ ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ } + + +/*N*/ void __EXPORT EditEngine::ParagraphHeightChanged( sal_uInt16 nPara ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ +/*N*/ if ( GetNotifyHdl().IsSet() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EENotify aNotify( EE_NOTIFY_TEXTHEIGHTCHANGED ); +/*N*/ } +/*N*/ } + +/*N*/ XubString __EXPORT EditEngine::GetUndoComment( sal_uInt16 nId ) const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ XubString aComment; +/*N*/ switch ( nId ) +/*N*/ { +/*N*/ case EDITUNDO_REMOVECHARS: +/*N*/ case EDITUNDO_CONNECTPARAS: +/*N*/ case EDITUNDO_REMOVEFEATURE: +/*N*/ case EDITUNDO_DELCONTENT: +/*N*/ case EDITUNDO_DELETE: +/*N*/ case EDITUNDO_CUT: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_DEL ) ); +/*N*/ break; +/*N*/ case EDITUNDO_MOVEPARAGRAPHS: +/*N*/ case EDITUNDO_MOVEPARAS: +/*N*/ case EDITUNDO_DRAGANDDROP: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_MOVE ) ); +/*N*/ break; +/*N*/ case EDITUNDO_INSERTFEATURE: +/*N*/ case EDITUNDO_SPLITPARA: +/*N*/ case EDITUNDO_INSERTCHARS: +/*N*/ case EDITUNDO_PASTE: +/*N*/ case EDITUNDO_INSERT: +/*N*/ case EDITUNDO_READ: +/*N*/ aComment = XubString( EditResId( RID_EDITUNDO_INSERT ) ); +/*N*/ break; +/*N*/ case EDITUNDO_SRCHANDREPL: +/*N*/ case EDITUNDO_REPLACEALL: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_REPLACE ) ); +/*N*/ break; +/*N*/ case EDITUNDO_ATTRIBS: +/*N*/ case EDITUNDO_PARAATTRIBS: +/*N*/ case EDITUNDO_STRETCH: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_SETATTRIBS ) ); +/*N*/ break; +/*N*/ case EDITUNDO_RESETATTRIBS: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_RESETATTRIBS ) ); +/*N*/ break; +/*N*/ case EDITUNDO_STYLESHEET: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_SETSTYLE ) ); +/*N*/ break; +/*N*/ case EDITUNDO_TRANSLITERATE: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_TRANSLITERATE ) ); +/*N*/ break; +/*N*/ case EDITUNDO_INDENTBLOCK: +/*N*/ case EDITUNDO_UNINDENTBLOCK: +/*?*/ aComment = XubString( EditResId( RID_EDITUNDO_INDENT ) ); +/*N*/ break; +/*N*/ } +/*N*/ return aComment; +/*N*/ } + +/*N*/ Rectangle EditEngine::GetBulletArea( sal_uInt16 nPara ) +/*N*/ { +/*N*/ return Rectangle( Point(), Point() ); +/*N*/ } + +/*N*/ XubString __EXPORT EditEngine::CalcFieldValue( const SvxFieldItem& rField, sal_uInt16, sal_uInt16, Color*&, Color*& ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditEngine, 0 ); +/*N*/ return ' '; +/*N*/ } + + + +// ===================================================================== +// ====================== Statische Methoden ======================= +// ===================================================================== +/*N*/ SfxItemPool* EditEngine::CreatePool( sal_Bool bPersistentRefCounts ) +/*N*/ { +/*N*/ SfxItemPool* pPool = new EditEngineItemPool( bPersistentRefCounts ); +/*N*/ return pPool; +/*N*/ } + + +/*N*/ Font EditEngine::CreateFontFromItemSet( const SfxItemSet& rItemSet, USHORT nScriptType ) +/*N*/ { +/*N*/ SvxFont aFont; +/*N*/ CreateFont( aFont, rItemSet, nScriptType ); +/*N*/ return aFont; +/*N*/ } + +// Maybe we can remove the next two methods, check after 6.x + +/*N*/ SvxFont EditEngine::CreateSvxFontFromItemSet( const SfxItemSet& rItemSet ) +/*N*/ { +/*N*/ SvxFont aFont; +/*N*/ CreateFont( aFont, rItemSet ); +/*N*/ return aFont; +/*N*/ } + + +// Mal in den Outliner schieben... +/*N*/ void EditEngine::ImportBulletItem( SvxNumBulletItem& rNumBullet, sal_uInt16 nLevel, +/*N*/ const SvxBulletItem* pOldBullet, const SvxLRSpaceItem* pOldLRSpace ) +/*N*/ { +/*N*/ if ( pOldBullet || pOldLRSpace ) +/*N*/ { +/*N*/ // Numberformat dynamisch, weil Zuweisungsoperator nicht implementiert. +/*N*/ +/*N*/ // Altes NumBulletItem nur uebernehmen, wenn kein altes BulletItem +/*N*/ const SvxNumberFormat* pFmt = ( !pOldBullet && ( rNumBullet.GetNumRule()->GetLevelCount() > nLevel ) ) ? +/*N*/ rNumBullet.GetNumRule()->Get( nLevel ) : NULL; +/*N*/ SvxNumberFormat* pNumberFormat = pFmt +/*N*/ ? new SvxNumberFormat( *pFmt ) +/*N*/ : new SvxNumberFormat( SVX_NUM_NUMBER_NONE ); +/*N*/ if ( pOldBullet ) +/*N*/ { +/*N*/ // Style +/*N*/ SvxExtNumType eNumType; +/*N*/ switch( pOldBullet->GetStyle() ) +/*N*/ { +/*N*/ case BS_BMP: eNumType = SVX_NUM_BITMAP; break; +/*N*/ case BS_BULLET: eNumType = SVX_NUM_CHAR_SPECIAL; break; +/*N*/ case BS_ROMAN_BIG: eNumType = SVX_NUM_ROMAN_UPPER; break; +/*N*/ case BS_ROMAN_SMALL: eNumType = SVX_NUM_ROMAN_LOWER; break; +/*N*/ case BS_ABC_BIG: eNumType = SVX_NUM_CHARS_UPPER_LETTER; break; +/*N*/ case BS_ABC_SMALL: eNumType = SVX_NUM_CHARS_LOWER_LETTER; break; +/*N*/ case BS_123: eNumType = SVX_NUM_ARABIC; break; +/*N*/ default: eNumType = SVX_NUM_NUMBER_NONE; break; +/*N*/ } +/*N*/ pNumberFormat->SetNumberingType( eNumType ); +/*N*/ +/*N*/ // Justification +/*N*/ SvxAdjust eAdjust; +/*N*/ switch( pOldBullet->GetJustification() & (BJ_HRIGHT|BJ_HCENTER|BJ_HLEFT) ) +/*N*/ { +/*?*/ case BJ_HRIGHT: eAdjust = SVX_ADJUST_RIGHT; break; +/*?*/ case BJ_HCENTER: eAdjust = SVX_ADJUST_CENTER; break; +/*N*/ default: eAdjust = SVX_ADJUST_LEFT; break; +/*N*/ } +/*N*/ pNumberFormat->SetNumAdjust(eAdjust); +/*N*/ +/*N*/ // Prefix/Suffix +/*N*/ pNumberFormat->SetPrefix( pOldBullet->GetPrevText() ); +/*N*/ pNumberFormat->SetSuffix( pOldBullet->GetFollowText() ); +/*N*/ +/*N*/ //Font +/*N*/ if ( eNumType != SVX_NUM_BITMAP ) +/*N*/ { +/*N*/ Font aTmpFont = pOldBullet->GetFont(); +/*N*/ pNumberFormat->SetBulletFont( &aTmpFont ); +/*N*/ } +/*N*/ +/*N*/ // Color +/*N*/ pNumberFormat->SetBulletColor( pOldBullet->GetFont().GetColor() ); +/*N*/ +/*N*/ // Start +/*N*/ pNumberFormat->SetStart( pOldBullet->GetStart() ); +/*N*/ +/*N*/ // Scale +/*N*/ pNumberFormat->SetBulletRelSize( pOldBullet->GetScale() ); +/*N*/ +/*N*/ // Bullet/Bitmap +/*N*/ if( eNumType == SVX_NUM_CHAR_SPECIAL ) +/*N*/ { +/*N*/ pNumberFormat->SetBulletChar( pOldBullet->GetSymbol() ); +/*N*/ } +/*N*/ else if( eNumType == SVX_NUM_BITMAP ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 SvxBrushItem aBItem( Graphic( pOldBullet->GetBitmap() ), GPOS_NONE ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Einzug und Erstzeileneinzug +/*N*/ if ( pOldLRSpace ) +/*N*/ { +/*N*/ short nLSpace = (short)pOldLRSpace->GetTxtLeft(); +/*N*/ pNumberFormat->SetLSpace( nLSpace ); +/*N*/ pNumberFormat->SetAbsLSpace( nLSpace ); +/*N*/ pNumberFormat->SetFirstLineOffset( pOldLRSpace->GetTxtFirstLineOfst() ); +/*N*/ } +/*N*/ +/*N*/ rNumBullet.GetNumRule()->SetLevel( nLevel, *pNumberFormat ); +/*N*/ delete pNumberFormat; +/*N*/ } +/*N*/ } + + + +// --------------------------------------------------- + + +/*N*/ EFieldInfo::EFieldInfo() +/*N*/ { +/*N*/ pFieldItem = NULL; +/*N*/ } + + +/*N*/ EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, USHORT nPara, USHORT nPos ) : aPosition( nPara, nPos ) +/*N*/ { +/*N*/ pFieldItem = new SvxFieldItem( rFieldItem ); +/*N*/ } + +/*N*/ EFieldInfo::~EFieldInfo() +/*N*/ { +/*N*/ delete pFieldItem; +/*N*/ } + +/*N*/ EFieldInfo::EFieldInfo( const EFieldInfo& rFldInfo ) +/*N*/ { +/*N*/ *this = rFldInfo; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editeng.src b/binfilter/bf_svx/source/editeng/svx_editeng.src new file mode 100644 index 000000000000..8775bb4294e5 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editeng.src @@ -0,0 +1,454 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ +#define NO_LOCALIZE_EXPORT + +#include <editeng.hrc> +#include <helpid.hrc> + +String RID_EDITUNDO_DEL +{ + Text [ de ] = "Löschen" ; + Text [ en-US ] = "Delete" ; + Text[ pt ] = "Eliminar"; + Text[ ru ] = "Удалить"; + Text[ el ] = "Διαγραφή"; + Text[ nl ] = "Wissen"; + Text[ fr ] = "Supprimer"; + Text[ es ] = "Borrar"; + Text[ fi ] = "Poista"; + Text[ ca ] = "Suprimeix"; + Text[ it ] = "Elimina"; + Text[ sk ] = "Zmazať"; + Text[ da ] = "Slet"; + Text[ sv ] = "Radera"; + Text[ pl ] = "Usuń"; + Text[ pt-BR ] = "Excluir"; + Text[ th ] = "ลบ"; + Text[ ja ] = "削除"; + Text[ ko ] = "삭제"; + Text[ zh-CN ] = "删除"; + Text[ zh-TW ] = "刪除"; + Text[ tr ] = "Sil"; + Text[ hi-IN ] = "मिटाओ"; + Text[ ar ] = "حذف"; + Text[ he ] = "מחיקה"; +}; + +String RID_EDITUNDO_MOVE +{ + Text [ de ] = "Verschieben" ; + Text [ en-US ] = "Move" ; + Text[ pt ] = "Mover"; + Text[ ru ] = "Переместить"; + Text[ el ] = "Μετακίνηση"; + Text[ nl ] = "Verplaatsen"; + Text[ fr ] = "Déplacer"; + Text[ es ] = "Desplazar"; + Text[ fi ] = "Siirrä"; + Text[ ca ] = "Mou"; + Text[ it ] = "Sposta"; + Text[ sk ] = "Presunúť"; + Text[ da ] = "Flyt"; + Text[ sv ] = "Flytta"; + Text[ pl ] = "Przesuń"; + Text[ pt-BR ] = "Mover"; + Text[ th ] = "ย้าย"; + Text[ ja ] = "移動"; + Text[ ko ] = "이동"; + Text[ zh-CN ] = "移动"; + Text[ zh-TW ] = "移動"; + Text[ tr ] = "Taşı"; + Text[ hi-IN ] = "स्थानान्तर"; + Text[ ar ] = "إزاحة"; + Text[ he ] = "הזזה"; +}; + +String RID_EDITUNDO_INSERT +{ + Text [ de ] = "Einfügen" ; + Text [ en-US ] = "Insert" ; + Text[ pt ] = "Inserir"; + Text[ ru ] = "Вставить"; + Text[ el ] = "Εισαγωγή"; + Text[ nl ] = "Invoegen"; + Text[ fr ] = "Insérer"; + Text[ es ] = "Insertar"; + Text[ fi ] = "Lisää"; + Text[ ca ] = "Insereix"; + Text[ it ] = "Inserisci"; + Text[ sk ] = "Vložiť"; + Text[ da ] = "Indsæt"; + Text[ sv ] = "Infoga"; + Text[ pl ] = "Wstaw"; + Text[ pt-BR ] = "Inserir"; + Text[ th ] = "แทรก"; + Text[ ja ] = "挿入"; + Text[ ko ] = "삽입"; + Text[ zh-CN ] = "插入"; + Text[ zh-TW ] = "插入"; + Text[ tr ] = "Ekle"; + Text[ hi-IN ] = "जोड़ो"; + Text[ ar ] = "إدراج"; + Text[ he ] = "הוספה"; +}; + +String RID_EDITUNDO_REPLACE +{ + Text [ de ] = "Ersetzen" ; + Text [ en-US ] = "Replace" ; + Text[ pt ] = "Substituir"; + Text[ ru ] = "Заменить"; + Text[ el ] = "Αντικατάσταση"; + Text[ nl ] = "Vervangen"; + Text[ fr ] = "Remplacer"; + Text[ es ] = "Reemplazar"; + Text[ fi ] = "Korvaa"; + Text[ ca ] = "Reemplaça"; + Text[ it ] = "Sostituisci"; + Text[ sk ] = "Nahradiť"; + Text[ da ] = "Erstat"; + Text[ sv ] = "Ersätt"; + Text[ pl ] = "Zamień"; + Text[ pt-BR ] = "Substituir"; + Text[ th ] = "แทนที่"; + Text[ ja ] = "置換"; + Text[ ko ] = "바꾸기"; + Text[ zh-CN ] = "替换"; + Text[ zh-TW ] = "代替"; + Text[ tr ] = "Değiştir"; + Text[ hi-IN ] = "प्रतिस्थापन"; + Text[ ar ] = "استبدال"; + Text[ he ] = "החלפה"; +}; + +String RID_EDITUNDO_SETATTRIBS +{ + Text [ de ] = "Attribute anwenden" ; + Text [ en-US ] = "Apply attributes" ; + Text[ pt ] = "Aplicar atributos"; + Text[ ru ] = "Применить атрибуты"; + Text[ el ] = "Εφαρμογή ιδιοτήτων"; + Text[ nl ] = "Attributen toepassen"; + Text[ fr ] = "Appliquer les attributs"; + Text[ es ] = "Aplicar atributos"; + Text[ fi ] = "Käytä määritteitä"; + Text[ ca ] = "Aplica els atributs"; + Text[ it ] = "Applica attributi"; + Text[ sk ] = "Použiť atribúty"; + Text[ da ] = "Anvend attributter"; + Text[ sv ] = "Använd attribut"; + Text[ pl ] = "Zastosuj atrybuty"; + Text[ pt-BR ] = "Aplicar atributos"; + Text[ th ] = "ใช้คุณลักษณะ"; + Text[ ja ] = "属性を適用"; + Text[ ko ] = "속성 적용"; + Text[ zh-CN ] = "使用属性"; + Text[ zh-TW ] = "使用屬性"; + Text[ tr ] = "Öznitelikleri kullan"; + Text[ hi-IN ] = "ऐट्रिब्यूट्स लागू करो"; + Text[ ar ] = "استخدام السمات"; + Text[ he ] = "ישום תכונות"; +}; + +String RID_EDITUNDO_RESETATTRIBS +{ + Text [ de ] = "Attribute zurücksetzen" ; + Text [ en-US ] = "Reset attributes" ; + Text[ pt ] = "Repor atributos"; + Text[ ru ] = "Восстановить атрибуты"; + Text[ el ] = "Επαναφορά ιδιοτήτων"; + Text[ nl ] = "Attributen herstellen"; + Text[ fr ] = "Restaurer les attributs"; + Text[ es ] = "Restablecer atributos"; + Text[ fi ] = "Palauta määritteet"; + Text[ ca ] = "Reinicia els atributs"; + Text[ it ] = "Reimposta attributi"; + Text[ sk ] = "Obnoviť atribúty"; + Text[ da ] = "Nulstil attributer"; + Text[ sv ] = "Återställ attribut"; + Text[ pl ] = "Resetuj atrybuty"; + Text[ pt-BR ] = "Redefinir atributos"; + Text[ th ] = "กำหนดคุณลักษณะใหม่"; + Text[ ja ] = "属性を元に戻す"; + Text[ ko ] = "속성 원래대로"; + Text[ zh-CN ] = "重设属性"; + Text[ zh-TW ] = "重設屬性"; + Text[ tr ] = "Öznitelikleri başa al"; + Text[ hi-IN ] = "ऐट्रिब्यूट्स रिसेट्ट करो"; + Text[ ar ] = "إعادة تعيين السمات"; + Text[ he ] = "איפוס תכונות"; +}; + +String RID_EDITUNDO_INDENT +{ + Text [ de ] = "Einrücken" ; + Text [ en-US ] = "Indent" ; + Text[ pt ] = "Avançar"; + Text[ ru ] = "Отступ"; + Text[ el ] = "Εσοχή"; + Text[ nl ] = "Inspringing"; + Text[ fr ] = "Mettre en retrait"; + Text[ es ] = "Sangría"; + Text[ fi ] = "Sisennä"; + Text[ ca ] = "Sagnat"; + Text[ it ] = "Rientro"; + Text[ sk ] = "Odsadenie"; + Text[ da ] = "Indryk"; + Text[ sv ] = "Dra in"; + Text[ pl ] = "Wcięcie"; + Text[ pt-BR ] = "Recuo"; + Text[ th ] = "ระยะเยื้อง"; + Text[ ja ] = "挿入"; + Text[ ko ] = "들여쓰기"; + Text[ zh-CN ] = "缩进"; + Text[ zh-TW ] = "縮排"; + Text[ tr ] = "Girinti"; + Text[ hi-IN ] = "इन्डेन्ट"; + Text[ ar ] = "إزاحة"; + Text[ he ] = "כניסה"; +}; + +String RID_EDITUNDO_SETSTYLE +{ + Text [ de ] = "Vorlagen anwenden" ; + Text [ en-US ] = "Apply Styles" ; + Text[ pt ] = "Aplicar estilos"; + Text[ ru ] = "Применить стили"; + Text[ el ] = "Εφαρμογή προτύπων"; + Text[ nl ] = "Opmaakprofielen toepassen"; + Text[ fr ] = "Appliquer les styles"; + Text[ es ] = "Aplicar estilos"; + Text[ fi ] = "Käytä tyylejä"; + Text[ ca ] = "Aplica els estils"; + Text[ it ] = "Applica modelli"; + Text[ sk ] = "Použiť štýly"; + Text[ da ] = "Anvend typografier"; + Text[ sv ] = "Använd mallar"; + Text[ pl ] = "Zastosuj style"; + Text[ pt-BR ] = "Aplicar Estilos"; + Text[ th ] = "ใช้ลักษณะ"; + Text[ ja ] = "スタイルを適用"; + Text[ ko ] = "스타일 적용"; + Text[ zh-CN ] = "使用样式"; + Text[ zh-TW ] = "使用樣式"; + Text[ tr ] = "Şablonları kullan"; + Text[ hi-IN ] = "शैलियों को लागू करो"; + Text[ ar ] = "استخدام نماذج"; + Text[ he ] = "ישום סגנונות"; +}; + +String RID_EDITUNDO_TRANSLITERATE +{ + Text [ de ] = "Groß-/Kleinschreibung"; + Text [ en-US ] = "Case/Characters"; + Text [ x-comment ] = "; nk03.04.01: hier passt Englisch Uebesetzung besser."; + Text[ pt ] = "Caixa/Caracteres"; + Text[ ru ] = "Регистр"; + Text[ el ] = "Κεφαλαία/Πεζά"; + Text[ nl ] = "Hoofdletters/kleine letters"; + Text[ fr ] = "Casse/Caractères"; + Text[ es ] = "Mayúsculas/minúsculas"; + Text[ fi ] = "Muuta kirjainkoko"; + Text[ ca ] = "Majúscules/minúscules"; + Text[ it ] = "Maiuscole/minuscole"; + Text[ sk ] = "Veľkosť/znaky"; + Text[ da ] = "Store og små bogstaver"; + Text[ sv ] = "Bokstäver/tecken"; + Text[ pl ] = "Wielkie i małe litery"; + Text[ pt-BR ] = "Caixa/Caracteres"; + Text[ th ] = "ตัวพิมพ์/ตัวอักขระ"; + Text[ ja ] = "文字種の変換"; + Text[ ko ] = "문자 바꾸기"; + Text[ zh-CN ] = "变化字母和字体格式"; + Text[ zh-TW ] = "變化字母和字型格式"; + Text[ tr ] = "Koşul/Karakterler"; + Text[ hi-IN ] = "केस/अक्षरें"; + Text[ ar ] = "الكتابة بأحرف كبيرة أو صغيرة"; + Text[ he ] = "סיווג אותיות"; +}; + + +Menu RID_MENU_SPELL +{ + ItemList = + { + MenuItem + { + Identifier = MN_SPELLING ; + HelpId = HID_EDITENG_SPELLER_START; + Text [ de ] = "~Rechtschreibprüfung..." ; + Text [ en-US ] = "~Spellcheck..." ; + Text [ x-comment ] = "; triple dots (...) are required now at the end of the text"; + Text[ pt ] = "Or~tografia"; + Text[ ru ] = "~Проверка орфографии"; + Text[ el ] = "Ορθογραφικός έλεγχος"; + Text[ nl ] = "~Spellingcontrole"; + Text[ fr ] = "~Vérification orthographique..."; + Text[ es ] = "~Revisión ortográfica..."; + Text[ fi ] = "~Oikeinkirjoituksen tarkistus"; + Text[ ca ] = "~Ortografia"; + Text[ it ] = "Controllo ~ortografico..."; + Text[ sk ] = "~Kontrola pravopisu"; + Text[ da ] = "~Stavekontrol"; + Text[ sv ] = "~Rättstavning..."; + Text[ pl ] = "~Pisownia"; + Text[ pt-BR ] = "Verificação ~Ortográfica"; + Text[ th ] = "~ตรวจสอบการสะกด"; + Text[ ja ] = "文章校正(~S)..."; + Text[ ko ] = "맞춤법 검사(~S)..."; + Text[ zh-CN ] = "拼写检查(~S)..."; + Text[ zh-TW ] = "拼寫檢查(~S)..."; + Text[ tr ] = "~Yazım Kontrolü..."; + Text[ hi-IN ] = "~अक्षर की जाँच"; + Text[ ar ] = "تد~قيق إملائي"; + Text[ he ] = "בדיקת איות"; + }; + MenuItem + { + Identifier = MN_INSERT ; + HelpId = HID_EDITENG_SPELLER_ADDWORD; + SubMenu = Menu + { + }; + Text [ de ] = "~Aufnehmen" ; + Text [ en-US ] = "~Add" ; + Text[ pt ] = "~Adicionar"; + Text[ ru ] = "Добавить"; + Text[ el ] = "Πρ~οσθήκη"; + Text[ nl ] = "~Toevoegen"; + Text[ fr ] = "~Ajouter"; + Text[ es ] = "~Incluir"; + Text[ fi ] = "Lis~ää"; + Text[ ca ] = "~Afegeix"; + Text[ it ] = "A~ggiungi"; + Text[ sk ] = "Prid~ať"; + Text[ da ] = "Ti~lføj"; + Text[ sv ] = "~Lägg till"; + Text[ pl ] = "~Dodaj"; + Text[ pt-BR ] = "~Adicionar"; + Text[ th ] = "เ~พิ่ม"; + Text[ ja ] = "追加(~A)"; + Text[ ko ] = "추가(~A)"; + Text[ zh-CN ] = "加入(~A)"; + Text[ zh-TW ] = "加入(~A)"; + Text[ tr ] = "Ekle"; + Text[ hi-IN ] = "~जोड़ो"; + Text[ ar ] = "إضافة"; + Text[ he ] = "הוספה"; + }; + MenuItem + { + Identifier = MN_IGNORE ; + HelpId = HID_EDITENG_SPELLER_IGNORE; + Text [ de ] = "Alle i~gnorieren" ; + Text [ en-US ] = "Ignore All" ; + Text[ pt ] = "I~gnorar tudo"; + Text[ ru ] = "Пропустить все"; + Text[ el ] = "Παρά~βλεψη όλων"; + Text[ nl ] = "Alle ~negeren"; + Text[ fr ] = "Tout ~ignorer"; + Text[ es ] = "I~gnorar todo"; + Text[ fi ] = "Ohita kaikki"; + Text[ ca ] = "Ignora'ls tots"; + Text[ it ] = "~Ignora tutto"; + Text[ sk ] = "Ignorovať všetko"; + Text[ da ] = "I~gnorer alle"; + Text[ sv ] = "~Ignorera alla"; + Text[ pl ] = "Ignoruj wszystko"; + Text[ pt-BR ] = "Ignorar Tudo"; + Text[ th ] = "เพิกเฉยทั้งหมด"; + Text[ ja ] = "すべて無視する"; + Text[ ko ] = "모두 무시"; + Text[ zh-CN ] = "全部忽略"; + Text[ zh-TW ] = "全部忽略"; + Text[ tr ] = "Tümünü yok say"; + Text[ hi-IN ] = "सब उपेक्षा करो"; + Text[ ar ] = "تجاهل الكل"; + Text[ he ] = "התעלמות מהכל"; + }; + MenuItem + { + Identifier = MN_AUTOCORR ; + HelpId = HID_EDITENG_SPELLER_AUTOCORRECT; + SubMenu = Menu + { + }; + Text [ de ] = "Auto~Korrektur" ; + Text [ en-US ] = "AutoCorrect" ; + Text[ pt ] = "Auto~Correcção"; + Text[ ru ] = "Автозамена"; + Text[ el ] = "Αυτόματη ~Διόρθωση"; + Text[ nl ] = "~AutoCorrectie"; + Text[ fr ] = "AutoCo~rrection"; + Text[ es ] = "~Corrección automática"; + Text[ fi ] = "Automaattinen korjaus"; + Text[ ca ] = "Auto~correcció"; + Text[ it ] = "~Correzione automatica"; + Text[ sk ] = "Automatické opravy"; + Text[ da ] = "Auto~Korrektur"; + Text[ sv ] = "Auto~Korrigering"; + Text[ pl ] = "Autokorekta"; + Text[ pt-BR ] = "AutoCorreção"; + Text[ th ] = "แก้ไขอัตโนมัติ"; + Text[ ja ] = "オートコレクト"; + Text[ ko ] = "자동 수정"; + Text[ zh-CN ] = "自动更正"; + Text[ zh-TW ] = "自動校正"; + Text[ tr ] = "Otomatik düzeltme"; + Text[ hi-IN ] = "स्वयं ठीक करो"; + Text[ ar ] = "تصحيح تلقائي"; + Text[ he ] = "תיקון אוטומטי"; + }; + }; +}; + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/binfilter/bf_svx/source/editeng/svx_editobj.cxx b/binfilter/bf_svx/source/editeng/svx_editobj.cxx new file mode 100644 index 000000000000..bed0287f1ca8 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editobj.cxx @@ -0,0 +1,1529 @@ +/* -*- 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. + * + ************************************************************************/ + + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//#define ENABLE_STRING_STREAM_OPERATORS + +#include <vcl/outdev.hxx> + +#include <editobj2.hxx> +#include <editeng.hxx> +#include <fontitem.hxx> +#include <cscoitem.hxx> + +#include "itemdata.hxx" + +#include <flditem.hxx> +#include <lrspitem.hxx> +#include <tstpitem.hxx> +#include <bulitem.hxx> +#include <numitem.hxx> +#include <brshitem.hxx> +#include <bf_svtools/intitem.hxx> + +#include <tools/tenccvt.hxx> +namespace binfilter { + +/*N*/ DBG_NAME( EE_EditTextObject ) +/*N*/ DBG_NAME( XEditAttribute ) + +//-------------------------------------------------------------- + +/*N*/ BOOL lcl_CreateBulletItem( const SvxNumBulletItem& rNumBullet, USHORT nLevel, SvxBulletItem& rBullet ) +/*N*/ { +/*N*/ const SvxNumberFormat* pFmt = rNumBullet.GetNumRule()->Get( nLevel ); +/*N*/ if ( pFmt ) +/*N*/ { +/*N*/ rBullet.SetWidth( (-pFmt->GetFirstLineOffset()) + pFmt->GetCharTextDistance() ); +/*N*/ rBullet.SetSymbol( pFmt->GetBulletChar() ); +/*N*/ rBullet.SetPrevText( pFmt->GetPrefix() ); +/*N*/ rBullet.SetFollowText( pFmt->GetSuffix() ); +/*N*/ rBullet.SetStart( pFmt->GetStart() ); +/*N*/ rBullet.SetScale( pFmt->GetBulletRelSize() ); +/*N*/ +/*N*/ Font aBulletFont( rBullet.GetFont() ); +/*N*/ if ( pFmt->GetBulletFont() ) +/*N*/ aBulletFont = *pFmt->GetBulletFont(); +/*N*/ aBulletFont.SetColor( pFmt->GetBulletColor() ); +/*N*/ rBullet.SetFont( aBulletFont ); +/*N*/ +/*N*/ if ( pFmt->GetBrush() && pFmt->GetBrush()->GetGraphic() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 Bitmap aBmp( pFmt->GetBrush()->GetGraphic()->GetBitmap() ); +/*N*/ } +/*N*/ +/*N*/ switch ( pFmt->GetNumberingType() ) +/*N*/ { +/*?*/ case SVX_NUM_CHARS_UPPER_LETTER: +/*?*/ case SVX_NUM_CHARS_UPPER_LETTER_N: +/*?*/ rBullet.SetStyle( BS_ABC_BIG ); +/*?*/ break; +/*?*/ case SVX_NUM_CHARS_LOWER_LETTER: +/*?*/ case SVX_NUM_CHARS_LOWER_LETTER_N: +/*?*/ rBullet.SetStyle( BS_ABC_SMALL ); +/*?*/ break; +/*?*/ case SVX_NUM_ROMAN_UPPER: +/*?*/ rBullet.SetStyle( BS_ROMAN_BIG ); +/*?*/ break; +/*?*/ case SVX_NUM_ROMAN_LOWER: +/*?*/ rBullet.SetStyle( BS_ROMAN_SMALL ); +/*?*/ break; +/*?*/ case SVX_NUM_ARABIC: +/*?*/ rBullet.SetStyle( BS_123 ); +/*?*/ break; +/*?*/ case SVX_NUM_NUMBER_NONE: +/*?*/ rBullet.SetStyle( BS_NONE ); +/*?*/ break; +/*?*/ case SVX_NUM_CHAR_SPECIAL: +/*N*/ rBullet.SetStyle( BS_BULLET ); +/*N*/ break; +/*?*/ case SVX_NUM_PAGEDESC: +/*?*/ DBG_ERROR( "Unknown: SVX_NUM_PAGEDESC" ); +/*?*/ rBullet.SetStyle( BS_BULLET ); +/*?*/ break; +/*?*/ case SVX_NUM_BITMAP: +/*?*/ rBullet.SetStyle( BS_BMP ); +/*?*/ break; +/*?*/ default: +/*?*/ DBG_ERROR( "Unknown NumType" ); +/*N*/ } +/*N*/ +/*N*/ switch ( pFmt->GetNumAdjust() ) +/*N*/ { +/*N*/ case SVX_ADJUST_LEFT: +/*N*/ rBullet.SetJustification( BJ_VCENTER|BJ_HLEFT ); +/*N*/ break; +/*?*/ case SVX_ADJUST_RIGHT: +/*?*/ rBullet.SetJustification( BJ_VCENTER|BJ_HRIGHT ); +/*?*/ break; +/*?*/ case SVX_ADJUST_CENTER: +/*?*/ rBullet.SetJustification( BJ_VCENTER|BJ_HCENTER ); +/*?*/ break; +/*?*/ default: +/*?*/ DBG_ERROR( "Unknown or invalid NumAdjust" ); +/*N*/ } +/*N*/ } +/*N*/ return pFmt ? TRUE : FALSE; +/*N*/ } + + +/*N*/ XEditAttribute* MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ // das neue Attribut im Pool anlegen +/*N*/ const SfxPoolItem& rNew = rPool.Put( rItem ); +/*N*/ +/*N*/ XEditAttribute* pNew = new XEditAttribute( rNew, nStart, nEnd ); +/*N*/ return pNew; +/*N*/ } + + + +/*N*/ XEditAttribute::XEditAttribute( const SfxPoolItem& rAttr, USHORT nS, USHORT nE ) +/*N*/ { +/*N*/ DBG_CTOR( XEditAttribute, 0 ); +/*N*/ pItem = &rAttr; +/*N*/ nStart = nS; +/*N*/ nEnd = nE; +/*N*/ } + +/*N*/ XEditAttribute::~XEditAttribute() +/*N*/ { +/*N*/ DBG_DTOR( XEditAttribute, 0 ); +/*N*/ pItem = 0; // Gehoert dem Pool. +/*N*/ } + +/*N*/ XEditAttribute* XEditAttributeList::FindAttrib( USHORT nWhich, USHORT nChar ) const +/*N*/ { +/*N*/ for ( USHORT n = Count(); n; ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = GetObject( --n ); +/*N*/ if( ( pAttr->GetItem()->Which() == nWhich ) && ( pAttr->GetStart() <= nChar ) && ( pAttr->GetEnd() > nChar ) ) +/*N*/ return pAttr; +/*N*/ } +/*N*/ return NULL; +/*N*/ } + +/*N*/ ContentInfo::ContentInfo( SfxItemPool& rPool ) : aParaAttribs( rPool, EE_PARA_START, EE_CHAR_END ) +/*N*/ { +/*N*/ eFamily = SFX_STYLE_FAMILY_PARA; +/*N*/ pTempLoadStoreInfos = NULL; +/*N*/ } + +// Richtiger CopyCTOR unsinning, weil ich mit einem anderen Pool arbeiten muss! +/*N*/ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ) +/*N*/ : aParaAttribs( rPoolToUse, EE_PARA_START, EE_CHAR_END ) +/*N*/ { +/*N*/ pTempLoadStoreInfos = NULL; +/*N*/ // So sollten die Items im richtigen Pool landen! +/*N*/ aParaAttribs.Set( rCopyFrom.GetParaAttribs() ); +/*N*/ aText = rCopyFrom.GetText(); +/*N*/ aStyle = rCopyFrom.GetStyle(); +/*N*/ eFamily = rCopyFrom.GetFamily(); +/*N*/ +/*N*/ // Attribute kopieren... +/*N*/ for ( USHORT n = 0; n < rCopyFrom.GetAttribs().Count(); n++ ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = rCopyFrom.GetAttribs().GetObject( n ); +/*N*/ XEditAttribute* pMyAttr = MakeXEditAttribute( rPoolToUse, *pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd() ); +/*N*/ aAttribs.Insert( pMyAttr, aAttribs.Count() ); +/*N*/ } +/*N*/ } + +/*N*/ ContentInfo::~ContentInfo() +/*N*/ { +/*N*/ for ( USHORT nAttr = 0; nAttr < aAttribs.Count(); nAttr++ ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = aAttribs.GetObject(nAttr); +/*N*/ // Item aus Pool entfernen! +/*N*/ aParaAttribs.GetPool()->Remove( *pAttr->GetItem() ); +/*N*/ delete pAttr; +/*N*/ } +/*N*/ aAttribs.Remove( 0, aAttribs.Count() ); +/*N*/ } + +/*N*/ void ContentInfo::CreateLoadStoreTempInfos() +/*N*/ { +/*N*/ delete pTempLoadStoreInfos; +/*N*/ pTempLoadStoreInfos = new LoadStoreTempInfos; +/*N*/ } + +/*N*/ void ContentInfo::DestroyLoadStoreTempInfos() +/*N*/ { +/*N*/ delete pTempLoadStoreInfos; +/*N*/ pTempLoadStoreInfos = NULL; +/*N*/ } + +/*N*/ EditTextObject::EditTextObject( USHORT n) +/*N*/ { +/*N*/ DBG_CTOR( EE_EditTextObject, 0 ); +/*N*/ nWhich = n; +/*N*/ } + +/*N*/ EditTextObject::EditTextObject( const EditTextObject& r ) +/*N*/ { +/*N*/ DBG_CTOR( EE_EditTextObject, 0 ); +/*N*/ nWhich = r.nWhich; +/*N*/ } + +/*N*/ __EXPORT EditTextObject::~EditTextObject() +/*N*/ { +/*N*/ DBG_DTOR( EE_EditTextObject, 0 ); +/*N*/ } + +/*N*/ USHORT EditTextObject::GetParagraphCount() const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return 0; +/*N*/ } + +/*N*/ XubString EditTextObject::GetText( USHORT nParagraph ) const +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return XubString();//STRIP001 +/*N*/ } + +/*N*/ void EditTextObject::Insert( const EditTextObject& rObj, USHORT nPara ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + + + + +/*N*/ void EditTextObject::ClearPortionInfo() +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + + + + +/*N*/ void EditTextObject::MergeParaAttribs( const SfxItemSet& rAttribs, USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + + + +/*N*/ BOOL EditTextObject::HasField( TypeId aType ) const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ SfxItemSet EditTextObject::GetParaAttribs( USHORT nPara ) const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return SfxItemSet( *(SfxItemPool*)NULL ); +/*N*/ } + + + + + +/*N*/ void EditTextObject::GetStyleSheet( USHORT nPara, XubString& rName, SfxStyleFamily& eFamily ) const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ void EditTextObject::SetStyleSheet( USHORT nPara, const XubString& rName, const SfxStyleFamily& eFamily ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ BOOL __EXPORT EditTextObject::ChangeStyleSheets( const XubString&, SfxStyleFamily, +/*N*/ const XubString&, SfxStyleFamily ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void __EXPORT EditTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily, +/*N*/ const XubString& rOldName, const XubString& rNewName ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ USHORT EditTextObject::GetUserType() const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return 0; +/*N*/ } + +/*N*/ void EditTextObject::SetUserType( USHORT n ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + + + +/*N*/ BOOL EditTextObject::IsVertical() const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void EditTextObject::SetVertical( BOOL bVertical ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + + + +/*N*/ BOOL EditTextObject::Store( SvStream& rOStream ) const +/*N*/ { +/*N*/ if ( rOStream.GetError() ) +/*N*/ return FALSE; +/*N*/ +/*N*/ // Vorspann: +/*N*/ ULONG nStartPos = rOStream.Tell(); +/*N*/ +/*N*/ USHORT nWhich = Which(); +/*N*/ rOStream << nWhich; +/*N*/ +/*N*/ sal_uInt32 nStructSz = 0; +/*N*/ rOStream << nStructSz; +/*N*/ +/*N*/ // Eigene Daten: +/*N*/ StoreData( rOStream ); +/*N*/ +/*N*/ // Nachspann: +/*N*/ ULONG nEndPos = rOStream.Tell(); +/*N*/ nStructSz = nEndPos - nStartPos - sizeof( nWhich ) - sizeof( nStructSz ); +/*N*/ rOStream.Seek( nStartPos + sizeof( nWhich ) ); +/*N*/ rOStream << nStructSz; +/*N*/ rOStream.Seek( nEndPos ); +/*N*/ +/*N*/ return rOStream.GetError() ? FALSE : TRUE; +/*N*/ } + +/*N*/ EditTextObject* EditTextObject::Create( SvStream& rIStream, SfxItemPool* pGlobalTextObjectPool ) +/*N*/ { +/*N*/ ULONG nStartPos = rIStream.Tell(); +/*N*/ +/*N*/ // Ertmal sehen, was fuer ein Object... +/*N*/ USHORT nWhich; +/*N*/ rIStream >> nWhich; +/*N*/ +/*N*/ sal_uInt32 nStructSz; +/*N*/ rIStream >> nStructSz; +/*N*/ +/*N*/ DBG_ASSERT( ( nWhich == 0x22 /*EE_FORMAT_BIN300*/ ) || ( nWhich == EE_FORMAT_BIN ), "CreateTextObject: Unbekanntes Objekt!" ); +/*N*/ +/*N*/ if ( rIStream.GetError() ) +/*N*/ return NULL; +/*N*/ +/*N*/ EditTextObject* pTxtObj = NULL; +/*N*/ switch ( nWhich ) +/*N*/ { +/*N*/ case 0x22 /*BIN300*/: pTxtObj = new BinTextObject( 0 ); +/*N*/ ((BinTextObject*)pTxtObj)->CreateData300( rIStream ); +/*N*/ break; +/*N*/ case EE_FORMAT_BIN: pTxtObj = new BinTextObject( pGlobalTextObjectPool ); +/*N*/ pTxtObj->CreateData( rIStream ); +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ // Wenn ich das Format nicht kenne, ueberlese ich den Inhalt: +/*?*/ rIStream.SetError( EE_READWRITE_WRONGFORMAT ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Sicherstellen, dass der Stream an der richtigen Stelle hinterlassen wird. +/*N*/ ULONG nFullSz = sizeof( nWhich ) + sizeof( nStructSz ) + nStructSz; +/*N*/ rIStream.Seek( nStartPos + nFullSz ); +/*N*/ return pTxtObj; +/*N*/ } + + +/*N*/ void __EXPORT EditTextObject::StoreData( SvStream& rOStream ) const +/*N*/ { +/*N*/ DBG_ERROR( "StoreData: Basisklasse!" ); +/*N*/ } + +/*N*/ void __EXPORT EditTextObject::CreateData( SvStream& rIStream ) +/*N*/ { +/*N*/ DBG_ERROR( "CreateData: Basisklasse!" ); +/*N*/ } + +/*N*/ USHORT EditTextObject::GetVersion() const +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ return 0; +/*N*/ } + + +/*N*/ void EditTextObject::AdjustImportedLRSpaceItems( BOOL bTurnOfBullets ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ void EditTextObject::PrepareStore( SfxStyleSheetPool* pStyleSheetPool ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ void EditTextObject::FinishStore() +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ void EditTextObject::FinishLoad( SfxStyleSheetPool* pStyleSheetPool ) +/*N*/ { +/*N*/ DBG_ERROR( "V-Methode direkt vom EditTextObject!" ); +/*N*/ } + +/*N*/ BinTextObject::BinTextObject( SfxItemPool* pP ) : +/*N*/ EditTextObject( EE_FORMAT_BIN ) +/*N*/ { +/*N*/ nVersion = 0; +/*N*/ nMetric = 0xFFFF; +/*N*/ nUserType = 0; +/*N*/ nObjSettings = 0; +/*N*/ pPortionInfo = 0; +/*N*/ if ( pP ) +/*N*/ { +/*N*/ pPool = pP; +/*N*/ bOwnerOfPool = FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pPool = EditEngine::CreatePool(); +/*N*/ bOwnerOfPool = TRUE; +/*N*/ } +/*N*/ bVertical = FALSE; +/*N*/ bStoreUnicodeStrings = FALSE; +/*N*/ nScriptType = 0; +/*N*/ } + +/*N*/ BinTextObject::BinTextObject( const BinTextObject& r ) : +/*N*/ EditTextObject( r ) +/*N*/ { +/*N*/ nVersion = r.nVersion; +/*N*/ nMetric = r.nMetric; +/*N*/ nUserType = r.nUserType; +/*N*/ nObjSettings = r.nObjSettings; +/*N*/ bVertical = r.bVertical; +/*N*/ nScriptType = r.nScriptType; +/*N*/ pPortionInfo = NULL; // PortionInfo nicht kopieren +/*N*/ bStoreUnicodeStrings = FALSE; +/*N*/ if ( !r.bOwnerOfPool ) +/*N*/ { +/*N*/ // Dann den Pool mitverwenden +/*N*/ pPool = r.pPool; +/*N*/ bOwnerOfPool = FALSE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pPool = EditEngine::CreatePool(); +/*N*/ bOwnerOfPool = TRUE; +/*N*/ +/*N*/ } +/*N*/ +/*N*/ if ( bOwnerOfPool && pPool && r.pPool ) +/*N*/ pPool->SetDefaultMetric( r.pPool->GetMetric( DEF_METRIC ) ); +/*N*/ +/*N*/ for ( USHORT n = 0; n < r.aContents.Count(); n++ ) +/*N*/ { +/*N*/ ContentInfo* pOrg = r.aContents.GetObject( n ); +/*N*/ DBG_ASSERT( pOrg, "NULL-Pointer in ContentList!" ); +/*N*/ ContentInfo* pNew = new ContentInfo( *pOrg, *pPool ); +/*N*/ aContents.Insert( pNew, aContents.Count() ); +/*N*/ } +/*N*/ } + +/*N*/ __EXPORT BinTextObject::~BinTextObject() +/*N*/ { +/*N*/ ClearPortionInfo(); +/*N*/ DeleteContents(); +/*N*/ if ( bOwnerOfPool ) +/*N*/ { +/*N*/ // Nicht mehr, wegen 1xDefItems. +/*N*/ // siehe auch ~EditDoc(). +/*N*/ // pPool->ReleaseDefaults( TRUE /* bDelete */ ); +/*N*/ delete pPool; +/*N*/ } +/*N*/ } + +/*N*/ USHORT BinTextObject::GetUserType() const +/*N*/ { +/*N*/ return nUserType; +/*N*/ } + +/*N*/ void BinTextObject::SetUserType( USHORT n ) +/*N*/ { +/*N*/ nUserType = n; +/*N*/ } + + + +/*N*/ BOOL BinTextObject::IsVertical() const +/*N*/ { +/*N*/ return bVertical; +/*N*/ } + +/*N*/ void BinTextObject::SetVertical( BOOL b ) +/*N*/ { +/*N*/ if ( b != bVertical ) +/*N*/ { +/*?*/ bVertical = b; +/*?*/ ClearPortionInfo(); +/*N*/ } +/*N*/ } + + +/*N*/ void BinTextObject::SetScriptType( USHORT nType ) +/*N*/ { +/*N*/ nScriptType = nType; +/*N*/ } + + +/*N*/ void BinTextObject::DeleteContents() +/*N*/ { +/*N*/ for ( USHORT n = 0; n < aContents.Count(); n++ ) +/*N*/ { +/*N*/ ContentInfo* p = aContents.GetObject( n ); +/*N*/ DBG_ASSERT( p, "NULL-Pointer in ContentList!" ); +/*N*/ delete p; +/*N*/ } +/*N*/ aContents.Remove( 0, aContents.Count() ); +/*N*/ } + +/*N*/ EditTextObject* __EXPORT BinTextObject::Clone() const +/*N*/ { +/*N*/ return new BinTextObject( *this ); +/*N*/ } + +/*N*/ XEditAttribute* BinTextObject::CreateAttrib( const SfxPoolItem& rItem, USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ return MakeXEditAttribute( *pPool, rItem, nStart, nEnd ); +/*N*/ } + +/*N*/ void BinTextObject::DestroyAttrib( XEditAttribute* pAttr ) +/*N*/ { +/*N*/ pPool->Remove( *pAttr->GetItem() ); +/*N*/ delete pAttr; +/*N*/ } + +/*N*/ ContentInfo* BinTextObject::CreateAndInsertContent() +/*N*/ { +/*N*/ ContentInfo* pC = new ContentInfo( *pPool ); +/*N*/ aContents.Insert( pC, aContents.Count() ); +/*N*/ return pC; +/*N*/ } + +/*N*/ USHORT BinTextObject::GetParagraphCount() const +/*N*/ { +/*N*/ return aContents.Count(); +/*N*/ } + +/*N*/ XubString BinTextObject::GetText( USHORT nPara ) const +/*N*/ { +/*N*/ DBG_ASSERT( nPara < aContents.Count(), "BinTextObject::GetText: Absatz existiert nicht!" ); +/*N*/ if ( nPara < aContents.Count() ) +/*N*/ { +/*N*/ ContentInfo* pC = aContents[ nPara ]; +/*N*/ return pC->GetText(); +/*N*/ } +/*?*/ return XubString(); +/*N*/ } + +/*N*/ void BinTextObject::Insert( const EditTextObject& rObj, USHORT nDestPara ) +/*N*/ { +/*N*/ DBG_ASSERT( rObj.Which() == EE_FORMAT_BIN, "UTO: Unbekanntes Textobjekt" ); +/*N*/ +/*N*/ const BinTextObject& rBinObj = (const BinTextObject&)rObj; +/*N*/ +/*N*/ if ( nDestPara > aContents.Count() ) +/*N*/ nDestPara = aContents.Count(); +/*N*/ +/*N*/ const USHORT nParas = rBinObj.GetContents().Count(); +/*N*/ for ( USHORT nP = 0; nP < nParas; nP++ ) +/*N*/ { +/*N*/ ContentInfo* pC = rBinObj.GetContents()[ nP ]; +/*N*/ ContentInfo* pNew = new ContentInfo( *pC, *GetPool() ); +/*N*/ aContents.Insert( pNew, nDestPara+nP ); +/*N*/ } +/*N*/ ClearPortionInfo(); +/*N*/ } + + + + +/*N*/ void BinTextObject::ClearPortionInfo() +/*N*/ { +/*N*/ if ( pPortionInfo ) +/*N*/ { +/*?*/ for ( USHORT n = pPortionInfo->Count(); n; ) +/*?*/ delete pPortionInfo->GetObject( --n ); +/*?*/ delete pPortionInfo; +/*?*/ pPortionInfo = NULL; +/*N*/ } +/*N*/ } + + + + +/*N*/ void BinTextObject::MergeParaAttribs( const SfxItemSet& rAttribs, USHORT nStart, USHORT nEnd ) +/*N*/ { +/*N*/ BOOL bChanged = FALSE; +/*N*/ +/*N*/ for ( USHORT nPara = GetContents().Count(); nPara; ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( --nPara ); +/*N*/ +/*N*/ for ( USHORT nW = nStart; nW <= nEnd; nW++ ) +/*N*/ { +/*N*/ if ( ( pC->GetParaAttribs().GetItemState( nW, FALSE ) != SFX_ITEM_ON ) +/*N*/ && ( rAttribs.GetItemState( nW, FALSE ) == SFX_ITEM_ON ) ) +/*N*/ { +/*N*/ pC->GetParaAttribs().Put( rAttribs.Get( nW ) ); +/*N*/ bChanged = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bChanged ) +/*N*/ ClearPortionInfo(); +/*N*/ } + + + +/*N*/ BOOL BinTextObject::HasField( TypeId aType ) const +/*N*/ { +/*N*/ USHORT nParagraphs = GetContents().Count(); +/*N*/ for ( USHORT nPara = 0; nPara < nParagraphs; nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*N*/ USHORT nAttrs = pC->GetAttribs().Count(); +/*N*/ for ( USHORT nAttr = 0; nAttr < nAttrs; nAttr++ ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = pC->GetAttribs()[nAttr]; +/*N*/ if ( pAttr->GetItem()->Which() == EE_FEATURE_FIELD ) +/*N*/ { +/*N*/ if ( !aType ) +/*N*/ return TRUE; +/*N*/ +/*N*/ const SvxFieldData* pFldData = ((const SvxFieldItem*)pAttr->GetItem())->GetField(); +/*N*/ if ( pFldData && pFldData->IsA( aType ) ) +/*N*/ return TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ SfxItemSet BinTextObject::GetParaAttribs( USHORT nPara ) const +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*N*/ return pC->GetParaAttribs(); +/*N*/ } + + + + + +/*N*/ void BinTextObject::GetStyleSheet( USHORT nPara, XubString& rName, SfxStyleFamily& rFamily ) const +/*N*/ { +/*N*/ if ( nPara < aContents.Count() ) +/*N*/ { +/*N*/ ContentInfo* pC = aContents[ nPara ]; +/*N*/ rName = pC->GetStyle(); +/*N*/ rFamily = pC->GetFamily(); +/*N*/ } +/*N*/ } + +/*N*/ void BinTextObject::SetStyleSheet( USHORT nPara, const XubString& rName, const SfxStyleFamily& rFamily ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ BOOL BinTextObject::ImpChangeStyleSheets( +/*N*/ const XubString& rOldName, SfxStyleFamily eOldFamily, +/*N*/ const XubString& rNewName, SfxStyleFamily eNewFamily ) +/*N*/ { +/*N*/ const USHORT nParagraphs = GetContents().Count(); +/*N*/ BOOL bChanges = FALSE; +/*N*/ +/*N*/ for ( USHORT nPara = 0; nPara < nParagraphs; nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*N*/ if ( pC->GetFamily() == eOldFamily ) +/*N*/ { +/*N*/ if ( pC->GetStyle() == rOldName ) +/*N*/ { +/*N*/ pC->GetStyle() = rNewName; +/*N*/ pC->GetFamily() = eNewFamily; +/*N*/ bChanges = TRUE; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bChanges; +/*N*/ } + +/*N*/ BOOL __EXPORT BinTextObject::ChangeStyleSheets( +/*N*/ const XubString& rOldName, SfxStyleFamily eOldFamily, +/*N*/ const XubString& rNewName, SfxStyleFamily eNewFamily ) +/*N*/ { +/*N*/ BOOL bChanges = ImpChangeStyleSheets( rOldName, eOldFamily, rNewName, eNewFamily ); +/*N*/ if ( bChanges ) +/*N*/ ClearPortionInfo(); +/*N*/ +/*N*/ return bChanges; +/*N*/ } + +/*N*/ void __EXPORT BinTextObject::ChangeStyleSheetName( SfxStyleFamily eFamily, +/*N*/ const XubString& rOldName, const XubString& rNewName ) +/*N*/ { +/*N*/ ImpChangeStyleSheets( rOldName, eFamily, rNewName, eFamily ); +/*N*/ } + +/*N*/ void __EXPORT BinTextObject::StoreData( SvStream& rOStream ) const +/*N*/ { +/*N*/ USHORT nVer = 602; +/*N*/ rOStream << nVer; +/*N*/ +/*N*/ rOStream << bOwnerOfPool; +/*N*/ +/*N*/ // Erst den Pool speichern, spaeter nur noch Surregate +/*N*/ if ( bOwnerOfPool ) +/*N*/ { +/*N*/ GetPool()->SetFileFormatVersion( SOFFICE_FILEFORMAT_50 ); +/*N*/ GetPool()->Store( rOStream ); +/*N*/ } +/*N*/ +/*N*/ // Aktuelle Zeichensatz speichern... +/*N*/ // #90477# GetSOStoreTextEncoding: Bug in 5.2, when default char set is multi byte text encoding +/*N*/ rtl_TextEncoding eEncoding = GetSOStoreTextEncoding( gsl_getSystemTextEncoding(), (USHORT) rOStream.GetVersion() ); +/*N*/ rOStream << (USHORT) eEncoding; +/*N*/ +/*N*/ // Die Anzahl der Absaetze... +/*N*/ USHORT nParagraphs = GetContents().Count(); +/*N*/ rOStream << nParagraphs; +/*N*/ +/*N*/ char cFeatureConverted = ByteString( CH_FEATURE, eEncoding ).GetChar(0); +/*N*/ +/*N*/ // Die einzelnen Absaetze... +/*N*/ for ( USHORT nPara = 0; nPara < nParagraphs; nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*N*/ +/*N*/ // Text... +/*N*/ ByteString aText( pC->GetText(), eEncoding ); +/*N*/ +/*N*/ // Symbols? +/*N*/ BOOL bSymbolPara = FALSE; +/*N*/ if ( pC->GetLoadStoreTempInfos() && pC->GetLoadStoreTempInfos()->bSymbolParagraph_Store ) +/*N*/ { +/*?*/ DBG_ASSERT( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_ON, "Why bSymbolParagraph_Store?" ); +/*?*/ aText = ByteString( pC->GetText(), RTL_TEXTENCODING_SYMBOL ); +/*?*/ bSymbolPara = TRUE; +/*N*/ } +/*N*/ else if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO ); +/*N*/ if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) +/*N*/ { +/*?*/ aText = ByteString( pC->GetText(), RTL_TEXTENCODING_SYMBOL ); +/*?*/ bSymbolPara = TRUE; +/*N*/ } +/*N*/ } +/*N*/ for ( USHORT nA = 0; nA < pC->GetAttribs().Count(); nA++ ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = pC->GetAttribs().GetObject( nA ); +/*N*/ +/*N*/ if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem(); +/*N*/ if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ) +/*N*/ || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) +/*N*/ { +/*N*/ // Not correctly converted +/*N*/ String aPart( pC->GetText(), pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart() ); +/*N*/ ByteString aNew( aPart, rFontItem.GetCharSet() ); +/*N*/ aText.Erase( pAttr->GetStart(), pAttr->GetEnd() - pAttr->GetStart() ); +/*N*/ aText.Insert( aNew, pAttr->GetStart() ); +/*N*/ } +/*N*/ +/*N*/ // #88414# Convert StarSymbol back to StarBats +/*N*/ FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); +/*N*/ if ( hConv ) +/*N*/ { +/*N*/ // Don't create a new Attrib with StarBats font, MBR changed the +/*N*/ // SvxFontItem::Store() to store StarBats instead of StarSymbol! +/*N*/ for ( USHORT nChar = pAttr->GetStart(); nChar < pAttr->GetEnd(); nChar++ ) +/*N*/ { +/*N*/ sal_Unicode cOld = pC->GetText().GetChar( nChar ); +/*N*/ char cConv = ByteString::ConvertFromUnicode( ConvertFontToSubsFontChar( hConv, cOld ), RTL_TEXTENCODING_SYMBOL ); +/*N*/ if ( cConv ) +/*N*/ aText.SetChar( nChar, cConv ); +/*N*/ } +/*N*/ +/*N*/ DestroyFontToSubsFontConverter( hConv ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // #88414# Convert StarSymbol back to StarBats +/*N*/ // StarSymbol as paragraph attribute or in StyleSheet? +/*N*/ +/*N*/ FontToSubsFontConverter hConv = NULL; +/*N*/ if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ hConv = CreateFontToSubsFontConverter( ((const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO )).GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); +/*N*/ } +/*N*/ else if ( pC->GetStyle().Len() && pC->GetLoadStoreTempInfos() ) +/*N*/ { +/*?*/ hConv = pC->GetLoadStoreTempInfos()->hOldSymbolConv_Store; +/*N*/ } +/*N*/ +/*N*/ if ( hConv ) +/*N*/ { +/*?*/ for ( USHORT nChar = 0; nChar < pC->GetText().Len(); nChar++ ) +/*?*/ { +/*?*/ if ( !pC->GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) ) +/*?*/ { +/*?*/ sal_Unicode cOld = pC->GetText().GetChar( nChar ); +/*?*/ char cConv = ByteString::ConvertFromUnicode( ConvertFontToSubsFontChar( hConv, cOld ), RTL_TEXTENCODING_SYMBOL ); +/*?*/ if ( cConv ) +/*?*/ aText.SetChar( nChar, cConv ); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ DestroyFontToSubsFontConverter( hConv ); +/*?*/ +/*?*/ if ( pC->GetLoadStoreTempInfos() ) +/*?*/ pC->GetLoadStoreTempInfos()->hOldSymbolConv_Store = NULL; +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // Convert CH_FEATURE to CH_FEATURE_OLD +/*N*/ aText.SearchAndReplaceAll( cFeatureConverted, CH_FEATURE_OLD ); +/*N*/ rOStream.WriteByteString( aText ); +/*N*/ +/*N*/ // StyleName und Family... +/*N*/ rOStream.WriteByteString( ByteString( pC->GetStyle(), eEncoding ) ); +/*N*/ rOStream << (USHORT)pC->GetFamily(); +/*N*/ +/*N*/ // Absatzattribute... +/*N*/ pC->GetParaAttribs().Store( rOStream ); +/*N*/ +/*N*/ // Die Anzahl der Attribute... +/*N*/ USHORT nAttribs = pC->GetAttribs().Count(); +/*N*/ rOStream << nAttribs; +/*N*/ +/*N*/ // Und die einzelnen Attribute +/*N*/ // Items als Surregate => immer 8 Byte pro Attrib +/*N*/ // Which = 2; Surregat = 2; Start = 2; End = 2; +/*N*/ for ( USHORT nAttr = 0; nAttr < nAttribs; nAttr++ ) +/*N*/ { +/*N*/ XEditAttribute* pX = pC->GetAttribs().GetObject( nAttr ); +/*N*/ +/*N*/ rOStream << pX->GetItem()->Which(); +/*N*/ GetPool()->StoreSurrogate( rOStream, pX->GetItem() ); +/*N*/ rOStream << pX->GetStart(); +/*N*/ rOStream << pX->GetEnd(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Ab 400: +/*N*/ rOStream << nMetric; +/*N*/ +/*N*/ // Ab 600 +/*N*/ rOStream << nUserType; +/*N*/ rOStream << nObjSettings; +/*N*/ +/*N*/ // Ab 601 +/*N*/ rOStream << bVertical; +/*N*/ +/*N*/ // Ab 602 +/*N*/ rOStream << nScriptType; +/*N*/ +/*N*/ rOStream << bStoreUnicodeStrings; +/*N*/ if ( bStoreUnicodeStrings ) +/*N*/ { +/*?*/ for ( USHORT nPara = 0; nPara < nParagraphs; nPara++ ) +/*?*/ { +/*?*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*?*/ USHORT nL = pC->GetText().Len(); +/*?*/ rOStream << nL; +/*?*/ rOStream.Write( pC->GetText().GetBuffer(), nL*sizeof(sal_Unicode) ); +/*?*/ +/*?*/ // #91575# StyleSheetName must be Unicode too! +/*?*/ // Copy/Paste from EA3 to BETA or from BETA to EA3 not possible, not needed... +/*?*/ // If needed, change nL back to ULONG and increase version... +/*?*/ nL = pC->GetStyle().Len(); +/*?*/ rOStream << nL; +/*?*/ rOStream.Write( pC->GetStyle().GetBuffer(), nL*sizeof(sal_Unicode) ); +/*?*/ } +/*N*/ } +/*N*/ } + +/*N*/ void __EXPORT BinTextObject::CreateData( SvStream& rIStream ) +/*N*/ { +/*N*/ rIStream >> nVersion; +/*N*/ +/*N*/ // Das Textobject wurde erstmal mit der aktuellen Einstellung +/*N*/ // von pTextObjectPool erzeugt. +/*N*/ BOOL bOwnerOfCurrent = bOwnerOfPool; +/*N*/ rIStream >> bOwnerOfPool; +/*N*/ +/*N*/ if ( bOwnerOfCurrent && !bOwnerOfPool ) +/*N*/ { +/*N*/ // Es wurde ein globaler Pool verwendet, mir jetzt nicht uebergeben, +/*N*/ // aber ich brauche ihn! +/*?*/ DBG_ERROR( "Man gebe mir den globalen TextObjectPool!" ); +/*?*/ return; +/*N*/ } +/*N*/ else if ( !bOwnerOfCurrent && bOwnerOfPool ) +/*N*/ { +/*N*/ // Es soll ein globaler Pool verwendet werden, aber dieses +/*N*/ // Textobject hat einen eigenen. +/*N*/ pPool = EditEngine::CreatePool(); +/*N*/ } +/*N*/ +/*N*/ if ( bOwnerOfPool ) +/*N*/ GetPool()->Load( rIStream ); +/*N*/ +/*N*/ // CharSet, in dem gespeichert wurde: +/*N*/ USHORT nCharSet; +/*N*/ rIStream >> nCharSet; +/*N*/ +/*N*/ rtl_TextEncoding eSrcEncoding = GetSOLoadTextEncoding( (rtl_TextEncoding)nCharSet, (USHORT)rIStream.GetVersion() ); +/*N*/ +/*N*/ // Die Anzahl der Absaetze... +/*N*/ USHORT nParagraphs; +/*N*/ rIStream >> nParagraphs; +/*N*/ +/*N*/ // Die einzelnen Absaetze... +/*N*/ for ( ULONG nPara = 0; nPara < nParagraphs; nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = CreateAndInsertContent(); +/*N*/ +/*N*/ // Der Text... +/*N*/ ByteString aByteString; +/*N*/ rIStream.ReadByteString( aByteString ); +/*N*/ pC->GetText() = String( aByteString, eSrcEncoding ); +/*N*/ +/*N*/ // StyleName und Family... +/*N*/ rIStream.ReadByteString( pC->GetStyle(), eSrcEncoding ); +/*N*/ USHORT nStyleFamily; +/*N*/ rIStream >> nStyleFamily; +/*N*/ pC->GetFamily() = (SfxStyleFamily)nStyleFamily; +/*N*/ +/*N*/ // Absatzattribute... +/*N*/ pC->GetParaAttribs().Load( rIStream ); +/*N*/ +/*N*/ // Die Anzahl der Attribute... +/*N*/ USHORT nAttribs; +/*N*/ rIStream >> nAttribs; +/*N*/ +/*N*/ // Und die einzelnen Attribute +/*N*/ // Items als Surregate => immer 8 Byte pro Attrib +/*N*/ // Which = 2; Surregat = 2; Start = 2; End = 2; +/*N*/ USHORT nAttr; +/*N*/ for ( nAttr = 0; nAttr < nAttribs; nAttr++ ) +/*N*/ { +/*N*/ USHORT nWhich, nStart, nEnd; +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ rIStream >> nWhich; +/*N*/ nWhich = pPool->GetNewWhich( nWhich ); +/*N*/ pItem = pPool->LoadSurrogate( rIStream, nWhich, 0 ); +/*N*/ rIStream >> nStart; +/*N*/ rIStream >> nEnd; +/*N*/ if ( pItem ) +/*N*/ { +/*N*/ if ( pItem->Which() == EE_FEATURE_NOTCONV ) +/*N*/ { +/*?*/ pC->GetText().SetChar( nStart, ByteString::ConvertToUnicode( aByteString.GetChar( nStart ), ((SvxCharSetColorItem*)pItem)->GetCharSet() ) ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd ); +/*N*/ pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() ); +/*N*/ +/*N*/ if ( ( nWhich >= EE_FEATURE_START ) && ( nWhich <= EE_FEATURE_END ) ) +/*N*/ { +/*N*/ // Convert CH_FEATURE to CH_FEATURE_OLD +/*N*/ DBG_ASSERT( (BYTE) aByteString.GetChar( nStart ) == CH_FEATURE_OLD, "CreateData: CH_FEATURE expected!" ); +/*N*/ if ( (BYTE) aByteString.GetChar( nStart ) == CH_FEATURE_OLD ) +/*N*/ pC->GetText().SetChar( nStart, CH_FEATURE ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Symbol-Conversion neccessary? +/*N*/ // All Strings are converted with the SourceCharSet in CreateData()... +/*N*/ +/*N*/ // Keep old ByteString, maybe Symbol-Conversion neccessary, will be +/*N*/ // checked in FinishLoad(), I need the StyleSheetPool for this... +/*N*/ if ( pC->GetStyle().Len() && ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_ON ) ) +/*N*/ { +/*N*/ pC->CreateLoadStoreTempInfos(); +/*N*/ pC->GetLoadStoreTempInfos()->aOrgString_Load = aByteString; +/*N*/ } +/*N*/ +/*N*/ // But check for paragraph and character symbol attribs here, +/*N*/ // FinishLoad will not be called in OpenOffice Calc, no StyleSheets... +/*N*/ +/*N*/ BOOL bSymbolPara = FALSE; +/*N*/ if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO ); +/*N*/ if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) +/*N*/ { +/*N*/ pC->GetText() = String( aByteString, RTL_TEXTENCODING_SYMBOL ); +/*N*/ bSymbolPara = TRUE; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ for ( nAttr = pC->GetAttribs().Count(); nAttr; ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = pC->GetAttribs().GetObject( --nAttr ); +/*N*/ if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)*pAttr->GetItem(); +/*N*/ if ( ( !bSymbolPara && ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) ) +/*N*/ || ( bSymbolPara && ( rFontItem.GetCharSet() != RTL_TEXTENCODING_SYMBOL ) ) ) +/*N*/ { +/*N*/ // Not correctly converted +/*N*/ ByteString aPart( aByteString, pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart() ); +/*N*/ String aNew( aPart, rFontItem.GetCharSet() ); +/*N*/ pC->GetText().Erase( pAttr->GetStart(), pAttr->GetEnd()-pAttr->GetStart() ); +/*N*/ pC->GetText().Insert( aNew, pAttr->GetStart() ); +/*N*/ } +/*N*/ +/*N*/ // #88414# Convert StarMath and StarBats to StarSymbol +/*N*/ FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); +/*N*/ if ( hConv ) +/*N*/ { +/*N*/ SvxFontItem aNewFontItem( rFontItem ); +/*N*/ aNewFontItem.GetFamilyName() = GetFontToSubsFontName( hConv ); +/*N*/ +/*N*/ pC->GetAttribs().Remove( nAttr ); +/*N*/ XEditAttribute* pNewAttr = CreateAttrib( aNewFontItem, pAttr->GetStart(), pAttr->GetEnd() ); +/*N*/ pC->GetAttribs().Insert( pNewAttr, nAttr ); +/*N*/ DestroyAttrib( pAttr ); +/*N*/ +/*N*/ for ( USHORT nChar = pNewAttr->GetStart(); nChar < pNewAttr->GetEnd(); nChar++ ) +/*N*/ { +/*N*/ sal_Unicode cOld = pC->GetText().GetChar( nChar ); +/*N*/ DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" ); +/*N*/ sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld ); +/*N*/ if ( cConv ) +/*N*/ pC->GetText().SetChar( nChar, cConv ); +/*N*/ } +/*N*/ +/*N*/ DestroyFontToSubsFontConverter( hConv ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // #88414# Convert StarMath and StarBats to StarSymbol +/*N*/ // Maybe old symbol font as paragraph attribute? +/*N*/ if ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO ); +/*N*/ FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_IMPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); +/*N*/ if ( hConv ) +/*N*/ { +/*N*/ SvxFontItem aNewFontItem( rFontItem ); +/*N*/ aNewFontItem.GetFamilyName() = GetFontToSubsFontName( hConv ); +/*N*/ pC->GetParaAttribs().Put( aNewFontItem ); +/*N*/ +/*N*/ for ( USHORT nChar = 0; nChar < pC->GetText().Len(); nChar++ ) +/*N*/ { +/*N*/ if ( !pC->GetAttribs().FindAttrib( EE_CHAR_FONTINFO, nChar ) ) +/*N*/ { +/*N*/ sal_Unicode cOld = pC->GetText().GetChar( nChar ); +/*N*/ DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" ); +/*N*/ sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld ); +/*N*/ if ( cConv ) +/*N*/ pC->GetText().SetChar( nChar, cConv ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ DestroyFontToSubsFontConverter( hConv ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Ab 400 auch die DefMetric: +/*N*/ if ( nVersion >= 400 ) +/*N*/ { +/*N*/ USHORT nTmpMetric; +/*N*/ rIStream >> nTmpMetric; +/*N*/ if ( nVersion >= 401 ) +/*N*/ { +/*N*/ // In der 400 gab es noch einen Bug bei Textobjekten mit eigenem +/*N*/ // Pool, deshalb erst ab 401 auswerten. +/*N*/ nMetric = nTmpMetric; +/*N*/ if ( bOwnerOfPool && pPool && ( nMetric != 0xFFFF ) ) +/*N*/ pPool->SetDefaultMetric( (SfxMapUnit)nMetric ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( nVersion >= 600 ) +/*N*/ { +/*N*/ rIStream >> nUserType; +/*N*/ rIStream >> nObjSettings; +/*N*/ } +/*N*/ +/*N*/ if ( nVersion >= 601 ) +/*N*/ { +/*N*/ rIStream >> bVertical; +/*N*/ } +/*N*/ +/*N*/ if ( nVersion >= 602 ) +/*N*/ { +/*N*/ rIStream >> nScriptType; +/*N*/ +/*N*/ BOOL bUnicodeStrings; +/*N*/ rIStream >> bUnicodeStrings; +/*N*/ if ( bUnicodeStrings ) +/*N*/ { +/*?*/ for ( USHORT nPara = 0; nPara < nParagraphs; nPara++ ) +/*?*/ { +/*?*/ ContentInfo* pC = GetContents().GetObject( nPara ); +/*?*/ USHORT nL; +/*?*/ +/*?*/ // Text +/*?*/ rIStream >> nL; +/*?*/ if ( nL ) +/*?*/ { +/*?*/ pC->GetText().AllocBuffer( nL ); +/*?*/ rIStream.Read( pC->GetText().GetBufferAccess(), nL*sizeof(sal_Unicode) ); +/*?*/ pC->GetText().ReleaseBufferAccess( (USHORT)nL ); +/*?*/ } +/*?*/ +/*?*/ // StyleSheetName +/*?*/ rIStream >> nL; +/*?*/ if ( nL ) +/*?*/ { +/*?*/ pC->GetStyle().AllocBuffer( nL ); +/*?*/ rIStream.Read( pC->GetStyle().GetBufferAccess(), nL*sizeof(sal_Unicode) ); +/*?*/ pC->GetStyle().ReleaseBufferAccess( (USHORT)nL ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // Ab 500 werden die Tabs anders interpretiert: TabPos + LI, vorher nur TabPos. +/*N*/ // Wirkt nur wenn auch Tab-Positionen eingestellt wurden, nicht beim DefTab. +/*N*/ if ( nVersion < 500 ) +/*N*/ { +/*N*/ for ( USHORT n = 0; n < aContents.Count(); n++ ) +/*N*/ { +/*N*/ ContentInfo* pC = aContents.GetObject( n ); +/*N*/ const SvxLRSpaceItem& rLRSpace = (const SvxLRSpaceItem&) pC->GetParaAttribs().Get( EE_PARA_LRSPACE ); +/*N*/ if ( rLRSpace.GetTxtLeft() && ( pC->GetParaAttribs().GetItemState( EE_PARA_TABS ) == SFX_ITEM_ON ) ) +/*N*/ { +/*N*/ const SvxTabStopItem& rTabs = (const SvxTabStopItem&) pC->GetParaAttribs().Get( EE_PARA_TABS ); +/*N*/ SvxTabStopItem aNewTabs( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS ); +/*N*/ for ( USHORT t = 0; t < rTabs.Count(); t++ ) +/*N*/ { +/*N*/ const SvxTabStop& rT = rTabs[ t ]; +/*N*/ aNewTabs.Insert( SvxTabStop( rT.GetTabPos() - rLRSpace.GetTxtLeft(), +/*N*/ rT.GetAdjustment(), rT.GetDecimal(), rT.GetFill() ) ); +/*N*/ } +/*N*/ pC->GetParaAttribs().Put( aNewTabs ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ USHORT BinTextObject::GetVersion() const +/*N*/ { +/*N*/ return nVersion; +/*N*/ } + + +/*N*/ void BinTextObject::PrepareStore( SfxStyleSheetPool* pStyleSheetPool ) +/*N*/ { +/*N*/ // Some Items must be generated for the 5.0 file format, +/*N*/ // because we don't have a special format for 5.x or 6.x +/*N*/ USHORT nParas = GetContents().Count(); +/*N*/ const SvxNumBulletItem** ppNumBulletItems = new const SvxNumBulletItem*[nParas]; +/*N*/ for ( USHORT nPara = nParas; nPara; ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( --nPara ); +/*N*/ const SvxNumBulletItem* pSvxNumBulletItem = NULL; +/*N*/ const SfxPoolItem* pTmpItem = NULL; +/*N*/ if ( pC->GetParaAttribs().GetItemState(EE_PARA_NUMBULLET, FALSE, &pTmpItem ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ pSvxNumBulletItem = (const SvxNumBulletItem*)pTmpItem; +/*N*/ } +/*N*/ else if ( pStyleSheetPool && pC->GetStyle().Len() ) +/*N*/ { +/*N*/ SfxStyleSheet* pStyle = (SfxStyleSheet*)pStyleSheetPool->Find( pC->GetStyle(), pC->GetFamily() ); +/*N*/ if ( pStyle ) +/*N*/ pSvxNumBulletItem = &(const SvxNumBulletItem&)pStyle->GetItemSet().Get(EE_PARA_NUMBULLET); +/*N*/ } +/*N*/ +/*N*/ ppNumBulletItems[nPara] = pSvxNumBulletItem; +/*N*/ +/*N*/ if ( pSvxNumBulletItem ) +/*N*/ { +/*N*/ // Check if Item allready used, don't create a new one in this case. +/*N*/ BOOL bInserted = FALSE; +/*N*/ for ( USHORT nP = nPara+1; nP < nParas; nP++ ) +/*N*/ { +/*N*/ if ( ppNumBulletItems[nP] == pSvxNumBulletItem ) +/*N*/ { +/*N*/ ContentInfo* pTmpC = GetContents().GetObject( nP ); +/*N*/ pC->GetParaAttribs().Put( pTmpC->GetParaAttribs().Get( EE_PARA_BULLET ) ); +/*N*/ bInserted = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ if ( !bInserted ) +/*N*/ { +/*N*/ SvxBulletItem aNewBullet( EE_PARA_BULLET ); +/*N*/ const SfxUInt16Item& rLevel = (const SfxUInt16Item&) pC->GetParaAttribs().Get( EE_PARA_OUTLLEVEL ); +/*N*/ lcl_CreateBulletItem( *pSvxNumBulletItem, rLevel.GetValue(), aNewBullet ); +/*N*/ pC->GetParaAttribs().Put( aNewBullet ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // SymbolConvertion because of StyleSheet? +/*N*/ // Cannot be checked in StoreData, no StyleSheetPool, so do it here... +/*N*/ +/*N*/ pC->DestroyLoadStoreTempInfos(); // Maybe old infos, if somebody is not calling FinishLoad after CreateData, but PrepareStore... +/*N*/ +/*N*/ if ( ( pC->GetParaAttribs().GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_ON ) && pC->aStyle.Len() && pStyleSheetPool ) +/*N*/ { +/*N*/ SfxStyleSheet* pStyle = (SfxStyleSheet*)pStyleSheetPool->Find( pC->GetStyle(), pC->GetFamily() ); +/*N*/ if ( pStyle ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pStyle->GetItemSet().Get( EE_CHAR_FONTINFO ); +/*N*/ if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) +/*N*/ { +/*?*/ if ( !pC->GetLoadStoreTempInfos() ) +/*?*/ pC->CreateLoadStoreTempInfos(); +/*?*/ pC->GetLoadStoreTempInfos()->bSymbolParagraph_Store = TRUE; +/*N*/ } +/*N*/ +/*N*/ FontToSubsFontConverter hConv = CreateFontToSubsFontConverter( rFontItem.GetFamilyName(), FONTTOSUBSFONT_EXPORT | FONTTOSUBSFONT_ONLYOLDSOSYMBOLFONTS ); +/*N*/ if ( hConv ) +/*N*/ { +/*?*/ // #88414# Convert StarSymbol back to StarBats +/*?*/ if ( !pC->GetLoadStoreTempInfos() ) +/*?*/ pC->CreateLoadStoreTempInfos(); +/*?*/ pC->GetLoadStoreTempInfos()->hOldSymbolConv_Store = hConv; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ delete[] ppNumBulletItems; +/*N*/ } + +/*N*/ void BinTextObject::FinishStore() +/*N*/ { +/*N*/ for ( USHORT nPara = GetContents().Count(); nPara; ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( --nPara ); +/*N*/ pC->GetParaAttribs().ClearItem( EE_PARA_BULLET ); +/*N*/ +/*N*/ pC->DestroyLoadStoreTempInfos(); +/*N*/ } +/*N*/ } + +/*N*/ void BinTextObject::FinishLoad( SfxStyleSheetPool* pStyleSheetPool ) +/*N*/ { +/*N*/ BOOL bCreateNumBulletItem = nVersion && ( nVersion < 501 ); +/*N*/ for ( USHORT nPara = GetContents().Count(); nPara; ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( --nPara ); +/*N*/ +/*N*/ if( GetUserType() == 0x0003 ) // !! OUTLINERMODE_OUTLINEOBJECT !! +/*N*/ { +/*N*/ if ( pC->GetParaAttribs().GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ SvxNumBulletItem* pNumBullet = (SvxNumBulletItem*) &pC->GetParaAttribs().Get( EE_PARA_NUMBULLET ); +/*?*/ if( pNumBullet->GetNumRule()->GetNumRuleType() != SVX_RULETYPE_PRESENTATION_NUMBERING ) +/*?*/ { +/*?*/ pNumBullet->GetNumRule()->SetNumRuleType( SVX_RULETYPE_PRESENTATION_NUMBERING ); +/*?*/ pC->GetParaAttribs().Put( *pNumBullet, EE_PARA_NUMBULLET ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bCreateNumBulletItem ) +/*N*/ { +/*N*/ BOOL bBulletInPara = pC->GetParaAttribs().GetItemState( EE_PARA_BULLET ) == SFX_ITEM_ON; +/*N*/ BOOL bLRSpaceInPara = pC->GetParaAttribs().GetItemState( EE_PARA_LRSPACE ) == SFX_ITEM_ON; +/*N*/ +/*N*/ // Nur wenn ein Attribut hart gesetzt, ansonsten muss es in den Vorlagen +/*N*/ // richtig konvertiert sein. +/*N*/ +/*N*/ if ( bBulletInPara || bLRSpaceInPara ) +/*N*/ { +/*N*/ const SvxBulletItem* pBullet = NULL; +/*N*/ const SvxLRSpaceItem* pLRSpace = NULL; +/*N*/ SvxNumBulletItem* pNumBullet = NULL; +/*N*/ SfxStyleSheet* pStyle = NULL; +/*N*/ +/*N*/ if ( pC->GetStyle().Len() ) +/*N*/ pStyle = (SfxStyleSheet*)pStyleSheetPool->Find( pC->GetStyle(), pC->GetFamily() ); +/*N*/ +/*N*/ const SfxUInt16Item& rLevel = (const SfxUInt16Item&) pC->GetParaAttribs().Get( EE_PARA_OUTLLEVEL ); +/*N*/ USHORT nLevel = rLevel.GetValue(); +/*N*/ +/*N*/ if ( !pStyle || bBulletInPara ) +/*N*/ pBullet = (const SvxBulletItem*) &pC->GetParaAttribs().Get( EE_PARA_BULLET ); +/*N*/ else +/*N*/ pBullet = (const SvxBulletItem*) &pStyle->GetItemSet().Get( EE_PARA_BULLET ); +/*N*/ +/*N*/ if ( !pStyle || bLRSpaceInPara ) +/*N*/ pLRSpace = (const SvxLRSpaceItem*) &pC->GetParaAttribs().Get( EE_PARA_LRSPACE ); +/*N*/ else +/*?*/ pLRSpace = (const SvxLRSpaceItem*) &pStyle->GetItemSet().Get( EE_PARA_LRSPACE ); +/*N*/ +/*N*/ if ( !pStyle || ( pC->GetParaAttribs().GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON ) ) +/*?*/ pNumBullet = (SvxNumBulletItem*) &pC->GetParaAttribs().Get( EE_PARA_NUMBULLET ); +/*N*/ else +/*N*/ pNumBullet = (SvxNumBulletItem*) &pStyle->GetItemSet().Get( EE_PARA_NUMBULLET ); +/*N*/ +/*N*/ SvxNumBulletItem aNumBullet( *pNumBullet ); +/*N*/ EditEngine::ImportBulletItem( aNumBullet, nLevel, pBullet, pLRSpace ); +/*N*/ pC->GetParaAttribs().Put( aNumBullet ); +/*N*/ +/*N*/ if ( bLRSpaceInPara ) +/*N*/ pC->GetParaAttribs().ClearItem( EE_PARA_LRSPACE ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Symbol-Convertion because of StyleSheet? +/*N*/ if ( pStyleSheetPool && pC->GetLoadStoreTempInfos() && pC->GetLoadStoreTempInfos()->aOrgString_Load.Len() ) +/*N*/ { +/*N*/ SfxStyleSheet* pStyle = (SfxStyleSheet*)pStyleSheetPool->Find( pC->GetStyle(), pC->GetFamily() ); +/*N*/ if ( pStyle ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pStyle->GetItemSet().Get( EE_CHAR_FONTINFO ); +/*N*/ if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL ) +/*N*/ { +/*?*/ String aConverted( pC->GetLoadStoreTempInfos()->aOrgString_Load, RTL_TEXTENCODING_SYMBOL ); +/*?*/ +/*?*/ // Replace only Parts without hard font attribute, other symbol encoding +/*?*/ // is already done in CreateData()... +/*?*/ +/*?*/ USHORT nLastEnd = 0; +/*?*/ for ( USHORT nAttr = 0; nAttr < pC->GetAttribs().Count(); nAttr++ ) +/*?*/ { +/*?*/ XEditAttribute* pAttr = pC->GetAttribs().GetObject( nAttr ); +/*?*/ if ( pAttr->GetItem()->Which() == EE_CHAR_FONTINFO ) +/*?*/ { +/*?*/ if ( nLastEnd < pAttr->GetStart() ) +/*?*/ { +/*?*/ USHORT nLen = pAttr->GetStart() - nLastEnd; +/*?*/ pC->GetText().Erase( nLastEnd, nLen ); +/*?*/ pC->GetText().Insert( aConverted, nLastEnd, nLen, nLastEnd ); +/*?*/ } +/*?*/ nLastEnd = pAttr->GetEnd(); +/*?*/ +/*?*/ } +/*?*/ } +/*?*/ if ( nLastEnd < pC->GetText().Len() ) +/*?*/ { +/*?*/ USHORT nLen = pC->GetText().Len() - nLastEnd; +/*?*/ pC->GetText().Erase( nLastEnd, nLen ); +/*?*/ pC->GetText().Insert( aConverted, nLastEnd, nLen, nLastEnd ); +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pC->DestroyLoadStoreTempInfos(); +/*N*/ +/*N*/ // MT 07/00: EE_PARA_BULLET no longer needed +/*N*/ pC->GetParaAttribs().ClearItem( EE_PARA_BULLET ); +/*N*/ } +/*N*/ } + +/*N*/ void BinTextObject::AdjustImportedLRSpaceItems( BOOL bTurnOfBullets ) +/*N*/ { +/*N*/ for ( USHORT nPara = GetContents().Count(); nPara; ) +/*N*/ { +/*N*/ ContentInfo* pC = GetContents().GetObject( --nPara ); +/*N*/ if ( !bTurnOfBullets ) +/*N*/ { +/*N*/ for ( USHORT n = 0; n <=1; n++ ) +/*N*/ { +/*N*/ USHORT nItemId = n ? EE_PARA_LRSPACE : EE_PARA_OUTLLRSPACE; +/*N*/ if ( pC->GetParaAttribs().GetItemState( nItemId ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&) pC->GetParaAttribs().Get( nItemId ); +/*N*/ if ( !rItem.GetTxtFirstLineOfst() ) +/*N*/ { +/*N*/ SvxLRSpaceItem aNewItem( rItem ); +/*N*/ aNewItem.SetTxtFirstLineOfst( (short) -1200 ); // Outliner im Draw mit MAP100TH_MM +/*N*/ if( pC->GetParaAttribs().GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ const SvxNumBulletItem& rNumBullet = (const SvxNumBulletItem&) pC->GetParaAttribs().Get( EE_PARA_NUMBULLET ); +/*?*/ const SfxUInt16Item& rLevel = (const SfxUInt16Item&) pC->GetParaAttribs().Get( EE_PARA_OUTLLEVEL ); +/*?*/ const SvxNumberFormat* pFmt = rNumBullet.GetNumRule()->Get( rLevel.GetValue() ); +/*?*/ if ( pFmt ) +/*?*/ aNewItem.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() ); +/*N*/ } +/*N*/ pC->GetParaAttribs().Put( aNewItem ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Wurden in alten Versionen vom Outliner mal am Absatz gesetzt, soll nicht mehr sein +/*N*/ if ( !bTurnOfBullets && ( nVersion < 500 ) ) +/*N*/ { +/*N*/ for ( USHORT nW = EE_CHAR_START; nW <= EE_CHAR_END; nW++ ) +/*N*/ pC->GetParaAttribs().ClearItem( nW ); +/*N*/ } +/*N*/ +/*N*/ if ( bTurnOfBullets ) +/*N*/ { +/*N*/ SfxUInt16Item aBulletState( EE_PARA_BULLETSTATE, 0 ); +/*N*/ pC->GetParaAttribs().Put( aBulletState ); +/*N*/ } +/*N*/ } +/*N*/ } + + + +/*N*/ #define CHARSETMARKER 0x9999 + +/*N*/ void __EXPORT BinTextObject::CreateData300( SvStream& rIStream ) +/*N*/ { +/*N*/ // Fuer Aufwaertskompatibilitaet. +/*N*/ +/*N*/ // Erst den Pool laden... +/*N*/ // Ist in der 300 immer gespeichert worden! +/*N*/ GetPool()->Load( rIStream ); +/*N*/ +/*N*/ // Die Anzahl der Absaetze... +/*N*/ sal_uInt32 nParagraphs; +/*N*/ rIStream >> nParagraphs; +/*N*/ +/*N*/ // Die einzelnen Absaetze... +/*N*/ for ( sal_uInt32 nPara = 0; nPara < nParagraphs; nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = CreateAndInsertContent(); +/*N*/ +/*N*/ // Der Text... +/*N*/ rIStream.ReadByteString( pC->GetText() ); +/*N*/ +/*N*/ // StyleName und Family... +/*N*/ rIStream.ReadByteString( pC->GetStyle() ); +/*N*/ USHORT nStyleFamily; +/*N*/ rIStream >> nStyleFamily; +/*N*/ pC->GetFamily() = (SfxStyleFamily)nStyleFamily; +/*N*/ +/*N*/ // Absatzattribute... +/*N*/ pC->GetParaAttribs().Load( rIStream ); +/*N*/ +/*N*/ // Die Anzahl der Attribute... +/*N*/ sal_uInt32 nAttribs; +/*N*/ rIStream >> nAttribs; +/*N*/ +/*N*/ // Und die einzelnen Attribute +/*N*/ // Items als Surregate => immer 8 Byte pro Attrib +/*N*/ // Which = 2; Surregat = 2; Start = 2; End = 2; +/*N*/ for ( sal_uInt32 nAttr = 0; nAttr < nAttribs; nAttr++ ) +/*N*/ { +/*N*/ USHORT nWhich, nStart, nEnd; +/*N*/ const SfxPoolItem* pItem; +/*N*/ +/*N*/ rIStream >> nWhich; +/*N*/ nWhich = pPool->GetNewWhich( nWhich ); +/*N*/ pItem = pPool->LoadSurrogate( rIStream, nWhich, 0 ); +/*N*/ rIStream >> nStart; +/*N*/ rIStream >> nEnd; +/*N*/ if ( pItem ) +/*N*/ { +/*N*/ XEditAttribute* pAttr = new XEditAttribute( *pItem, nStart, nEnd ); +/*N*/ pC->GetAttribs().Insert( pAttr, pC->GetAttribs().Count() ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Prueffen, ob ein Zeichensatz gespeichert wurde +/*N*/ USHORT nCharSetMarker; +/*N*/ rIStream >> nCharSetMarker; +/*N*/ if ( nCharSetMarker == CHARSETMARKER ) +/*N*/ { +/*N*/ USHORT nCharSet; +/*N*/ rIStream >> nCharSet; +/*N*/ } +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editsel.cxx b/binfilter/bf_svx/source/editeng/svx_editsel.cxx new file mode 100644 index 000000000000..48cb2747a660 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editsel.cxx @@ -0,0 +1,112 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editview.hxx> +namespace binfilter { + +// ---------------------------------------------------------------------- +// class EditSelFunctionSet +// ---------------------------------------------------------------------- +/*N*/ EditSelFunctionSet::EditSelFunctionSet() +/*N*/ { +/*N*/ pCurView = NULL; +/*N*/ } + +/*N*/ void __EXPORT EditSelFunctionSet::CreateAnchor() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditSelFunctionSet::DestroyAnchor() +/*N*/ { +/*N*/ // Nur bei Mehrfachselektion +/*N*/ } + +/*N*/ BOOL __EXPORT EditSelFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOOL ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ return FALSE; +/*N*/ } + +/*N*/ BOOL __EXPORT EditSelFunctionSet::IsSelectionAtPoint( const Point& rPointPixel ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void __EXPORT EditSelFunctionSet::DeselectAtPoint( const Point& ) +/*N*/ { +/*N*/ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ // ! Implementieren, wenn Mehrfachselektion moeglich ! +/*N*/ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ } + +/*N*/ void __EXPORT EditSelFunctionSet::BeginDrag() +/*N*/ { +/*N*/ // Nur bei Mehrfachselektion +/*N*/ } + + +/*N*/ void __EXPORT EditSelFunctionSet::DeselectAll() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +// ---------------------------------------------------------------------- +// class EditSelectionEngine +// ---------------------------------------------------------------------- +/*N*/ EditSelectionEngine::EditSelectionEngine() : SelectionEngine( (Window*)0 ) +/*N*/ { +/*N*/ // Wegen Bug OV: (1994) +/*N*/ // 1995: RangeSelection lassen, SingleSelection nur fuer ListBoxen geeignet! +/*N*/ SetSelectionMode( RANGE_SELECTION ); +/*N*/ EnableDrag( TRUE ); +/*N*/ } + +/*N*/ void EditSelectionEngine::SetCurView( EditView* pNewView ) +/*N*/ { +/*N*/ if ( GetFunctionSet() ) +/*N*/ ((EditSelFunctionSet*)GetFunctionSet())->SetCurView( pNewView ); +/*N*/ +/*N*/ if ( pNewView ) +/*?*/ SetWindow( pNewView->GetWindow() ); +/*N*/ else +/*N*/ SetWindow( (Window*)0 ); +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editundo.cxx b/binfilter/bf_svx/source/editeng/svx_editundo.cxx new file mode 100644 index 000000000000..9cbb22fed8f4 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editundo.cxx @@ -0,0 +1,265 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> +namespace binfilter { + +DBG_NAME( EditUndo ) + +#define MAX_UNDOS 100 // ab dieser Menge darf geloescht werden.... +#define MIN_UNDOS 50 // soviel muss stehen bleiben... + +#define NO_UNDO 0xFFFF +#define GROUP_NOTFOUND 0xFFFF + +/*N*/ TYPEINIT1( EditUndoInsertChars, EditUndo ); + + +// ----------------------------------------------------------------------- +// EditUndoManager +// ------------------------------------------------------------------------ +/*N*/ EditUndoManager::EditUndoManager( ImpEditEngine* p ) +/*N*/ { +/*N*/ pImpEE = p; +/*N*/ } + + + +// ----------------------------------------------------------------------- +// EditUndo +// ------------------------------------------------------------------------ +/*N*/ EditUndo::EditUndo( USHORT nI, ImpEditEngine* p ) +/*N*/ { +/*N*/ DBG_CTOR( EditUndo, 0 ); +/*N*/ nId = nI; +/*N*/ pImpEE = p; +/*N*/ } + +/*N*/ EditUndo::~EditUndo() +/*N*/ { +/*N*/ DBG_DTOR( EditUndo, 0 ); +/*N*/ } + +/*N*/ USHORT __EXPORT EditUndo::GetId() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditUndo, 0 ); +/*N*/ return nId; +/*N*/ } + + +/*N*/ XubString __EXPORT EditUndo::GetComment() const +/*N*/ { +/*N*/ XubString aComment; +/*N*/ if ( pImpEE ) +/*N*/ { +/*N*/ EditEngine* pEditEng = pImpEE->GetEditEnginePtr(); +/*N*/ aComment = pEditEng->GetUndoComment( GetId() ); +/*N*/ } +/*N*/ return aComment; +/*N*/ } + +// ----------------------------------------------------------------------- +// EditUndoInsertChars +// ------------------------------------------------------------------------ +/*N*/ EditUndoInsertChars::EditUndoInsertChars( ImpEditEngine* pImpEE, const EPaM& rEPaM, const XubString& rStr ) +/*N*/ : EditUndo( EDITUNDO_INSERTCHARS, pImpEE ), +/*N*/ aEPaM( rEPaM ), aText( rStr ) +/*N*/ { +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertChars::Undo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertChars::Redo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ BOOL __EXPORT EditUndoInsertChars::Merge( SfxUndoAction* pNextAction ) +/*N*/ { +/*N*/ if ( !pNextAction->ISA( EditUndoInsertChars ) ) +/*N*/ return FALSE; +/*N*/ +/*N*/ EditUndoInsertChars* pNext = (EditUndoInsertChars*)pNextAction; +/*N*/ +/*N*/ if ( aEPaM.nPara != pNext->aEPaM.nPara ) +/*N*/ return FALSE; +/*N*/ +/*N*/ if ( ( aEPaM.nIndex + aText.Len() ) == pNext->aEPaM.nIndex ) +/*N*/ { +/*N*/ aText += pNext->aText; +/*N*/ return TRUE; +/*N*/ } +/*N*/ return FALSE; +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertChars::Repeat() +/*N*/ { +/*N*/ DBG_ERROR( "EditUndoInsertChars::Repeat nicht implementiert!" ); +/*N*/ } + +// ----------------------------------------------------------------------- +// EditUndoRemoveChars +// ------------------------------------------------------------------------ + + + + +// ----------------------------------------------------------------------- +// EditUndoInsertFeature +// ------------------------------------------------------------------------ +/*N*/ EditUndoInsertFeature::EditUndoInsertFeature( ImpEditEngine* pImpEE, const EPaM& rEPaM, const SfxPoolItem& rFeature) +/*N*/ : EditUndo( EDITUNDO_INSERTFEATURE, pImpEE ), aEPaM( rEPaM ) +/*N*/ { +/*N*/ pFeature = rFeature.Clone(); +/*N*/ DBG_ASSERT( pFeature, "Feature konnte nicht dupliziert werden: EditUndoInsertFeature" ); +/*N*/ } + +/*N*/ EditUndoInsertFeature::~EditUndoInsertFeature() +/*N*/ { +/*N*/ delete pFeature; +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertFeature::Undo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertFeature::Redo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoInsertFeature::Repeat() +/*N*/ { +/*N*/ DBG_ERROR( "EditUndoInsertFeature::Repeat nicht implementiert!" ); +/*N*/ } + +// ----------------------------------------------------------------------- +// EditUndoMoveParagraphs +// ------------------------------------------------------------------------ + + + + + +// ----------------------------------------------------------------------- +// EditUndoSetStyleSheet +// ------------------------------------------------------------------------ +/*N*/ EditUndoSetStyleSheet::EditUndoSetStyleSheet( ImpEditEngine* pImpEE, USHORT nP, +/*N*/ const XubString& rPrevName, SfxStyleFamily ePrevFam, +/*N*/ const XubString& rNewName, SfxStyleFamily eNewFam, +/*N*/ const SfxItemSet& rPrevParaAttribs ) +/*N*/ : EditUndo( EDITUNDO_STYLESHEET, pImpEE ), aPrevName( rPrevName ), aNewName( rNewName ), +/*N*/ aPrevParaAttribs( rPrevParaAttribs ) +/*N*/ { +/*N*/ ePrevFamily = ePrevFam; +/*N*/ eNewFamily = eNewFam; +/*N*/ nPara = nP; +/*N*/ } + +/*N*/ EditUndoSetStyleSheet::~EditUndoSetStyleSheet() +/*N*/ { +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetStyleSheet::Undo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetStyleSheet::Redo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetStyleSheet::Repeat() +/*N*/ { +/*N*/ DBG_ERROR( "EditUndoSetStyleSheet::Repeat nicht implementiert!" ); +/*N*/ } + +// ----------------------------------------------------------------------- +// EditUndoSetParaAttribs +// ------------------------------------------------------------------------ +/*N*/ EditUndoSetParaAttribs::EditUndoSetParaAttribs( ImpEditEngine* pImpEE, USHORT nP, const SfxItemSet& rPrevItems, const SfxItemSet& rNewItems ) +/*N*/ : EditUndo( EDITUNDO_PARAATTRIBS, pImpEE ), +/*N*/ aPrevItems( rPrevItems ), +/*N*/ aNewItems(rNewItems ) +/*N*/ { +/*N*/ nPara = nP; +/*N*/ } + +/*N*/ EditUndoSetParaAttribs::~EditUndoSetParaAttribs() +/*N*/ { +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetParaAttribs::Undo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetParaAttribs::Redo() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void __EXPORT EditUndoSetParaAttribs::Repeat() +/*N*/ { +/*N*/ DBG_ERROR( "EditUndoSetParaAttribs::Repeat nicht implementiert!" ); +/*N*/ } + +// ----------------------------------------------------------------------- +// EditUndoSetAttribs +// ------------------------------------------------------------------------ + + + + + + +// ----------------------------------------------------------------------- +// EditUndoTransliteration +// ------------------------------------------------------------------------ + + + + + +// ----------------------------------------------------------------------- +// EditUndoMarkSelection +// ------------------------------------------------------------------------ + + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_editview.cxx b/binfilter/bf_svx/source/editeng/svx_editview.cxx new file mode 100644 index 000000000000..1687133d8aa1 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_editview.cxx @@ -0,0 +1,214 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define _SOLAR__PRIVATE 1 + + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> +#include <editview.hxx> + + + +#include "itemdata.hxx" + + + +#include <editeng.hrc> +#include <helpid.hrc> + +#include <com/sun/star/beans/PropertyValues.hdl> +namespace binfilter { + +using namespace rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::linguistic2; + + +/*N*/ DBG_NAME( EditView ) + +// From SW => Create common method + + +/*N*/ EditView::~EditView() +/*N*/ { +/*N*/ DBG_DTOR( EditView, 0 ); +/*N*/ delete pImpEditView; +/*N*/ } + + +/*N*/ EditEngine* EditView::GetEditEngine() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 ); +/*N*/ return pImpEditView->pEditEngine; +/*N*/ } + +/*N*/ void EditView::SetSelection( const ESelection& rESel ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 ); +/*N*/ +/*N*/ // Falls jemand gerade ein leeres Attribut hinterlassen hat, +/*N*/ // und dann der Outliner die Selektion manipulitert: +/*N*/ if ( !pImpEditView->GetEditSelection().HasRange() ) +/*N*/ { +/*N*/ ContentNode* pNode = pImpEditView->GetEditSelection().Max().GetNode(); +/*N*/ PIMPEE->CursorMoved( pNode ); +/*N*/ } +/*N*/ EditSelection aNewSelection( PIMPEE->ConvertSelection( rESel.nStartPara, rESel.nStartPos, rESel.nEndPara, rESel.nEndPos ) ); +/*N*/ +/*N*/ // Selektion darf nicht bei einem unsichtbaren Absatz Starten/Enden: +/*N*/ ParaPortion* pPortion = PIMPEE->FindParaPortion( aNewSelection.Min().GetNode() ); +/*N*/ if ( !pPortion->IsVisible() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pPortion = PIMPEE->GetPrevVisPortion( pPortion ); +/*N*/ } +/*N*/ pPortion = PIMPEE->FindParaPortion( aNewSelection.Max().GetNode() ); +/*N*/ if ( !pPortion->IsVisible() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 pPortion = PIMPEE->GetPrevVisPortion( pPortion ); +/*N*/ } +/*N*/ +/*N*/ pImpEditView->DrawSelection(); // alte Selektion 'weg-zeichnen' +/*N*/ pImpEditView->SetEditSelection( aNewSelection ); +/*N*/ pImpEditView->DrawSelection(); +/*N*/ sal_Bool bGotoCursor = pImpEditView->DoAutoScroll(); +/*N*/ ShowCursor( bGotoCursor ); +/*N*/ } + +/*N*/ ESelection EditView::GetSelection() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 ); +/*N*/ +/*N*/ ESelection aSelection; +/*N*/ +/*N*/ aSelection.nStartPara = PIMPEE->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Min().GetNode() ); +/*N*/ aSelection.nEndPara = PIMPEE->GetEditDoc().GetPos( pImpEditView->GetEditSelection().Max().GetNode() ); +/*N*/ +/*N*/ aSelection.nStartPos = pImpEditView->GetEditSelection().Min().GetIndex(); +/*N*/ aSelection.nEndPos = pImpEditView->GetEditSelection().Max().GetIndex(); +/*N*/ +/*N*/ return aSelection; +/*N*/ } + +/*N*/ sal_Bool EditView::HasSelection() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ return pImpEditView->HasSelection(); +/*N*/ } + + + + + + +/*N*/ Window* EditView::GetWindow() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ return pImpEditView->pOutWin; +/*N*/ } + +/*N*/ const Rectangle& EditView::GetVisArea() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ // Change return value to Rectangle in next incompatible build !!! +/*N*/ static Rectangle aRect; +/*N*/ aRect = pImpEditView->GetVisDocArea(); +/*N*/ return aRect; +/*N*/ } + +/*N*/ const Rectangle& EditView::GetOutputArea() const +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ return pImpEditView->GetOutputArea(); +/*N*/ } + + +/*N*/ void EditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor ) +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ DBG_CHKOBJ( pImpEditView->pEditEngine, EditEngine, 0 ); +/*N*/ +/*N*/ // Draw vertraegt die Assertion nicht, spaeter mal aktivieren +/*N*/ // DBG_ASSERT( pImpEditView->pEditEngine->HasView( this ), "ShowCursor - View nicht angemeldet!" ); +/*N*/ // DBG_ASSERT( !GetWindow()->IsInPaint(), "ShowCursor - Why in Paint ?!" ); +/*N*/ +/*N*/ if ( pImpEditView->pEditEngine->HasView( this ) ) +/*N*/ { +/*N*/ // Das ControlWord hat mehr Gewicht: +/*N*/ if ( !pImpEditView->DoAutoScroll() ) +/*N*/ bGotoCursor = sal_False; +/*N*/ pImpEditView->ShowCursor( bGotoCursor, bForceVisCursor ); +/*N*/ } +/*N*/ } + +/*N*/ void EditView::HideCursor() +/*N*/ { +/*N*/ DBG_CHKTHIS( EditView, 0 ); +/*N*/ pImpEditView->GetCursor()->Hide(); +/*N*/ } + + + + + + + + + + + +#ifndef SVX_LIGHT +#endif + +/*N*/ void EditView::Cut() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void EditView::Copy() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/*N*/ void EditView::Paste() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_eerdll.cxx b/binfilter/bf_svx/source/editeng/svx_eerdll.cxx new file mode 100644 index 000000000000..d5b13e8b1f78 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_eerdll.cxx @@ -0,0 +1,239 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <bf_svtools/solar.hrc> +#include <eerdll.hxx> + + +#include <vcl/outdev.hxx> + +#include <eerdll2.hxx> + +#include "eeitem.hxx" +#include "eeitemid.hxx" + +#include <lspcitem.hxx> +#include <adjitem.hxx> +#include <tstpitem.hxx> +#include <bulitem.hxx> + + + +#include "itemdata.hxx" + + + +#include <flditem.hxx> +#include <emphitem.hxx> +#include <scriptspaceitem.hxx> + +#include <bf_svtools/itempool.hxx> + +#include <vcl/virdev.hxx> + +#include <vcl/svapp.hxx> + +#include <akrnitem.hxx> +#include <cntritem.hxx> +#include <crsditem.hxx> +#include <cscoitem.hxx> +#include <escpitem.hxx> +#include <fhgtitem.hxx> +#include <fontitem.hxx> +#include <kernitem.hxx> +#include <lrspitem.hxx> +#include <postitem.hxx> +#include <shdditem.hxx> +#include <udlnitem.hxx> +#include <ulspitem.hxx> +#include <wghtitem.hxx> +#include <wrlmitem.hxx> +#include <numitem.hxx> +#include <langitem.hxx> +#include <charscaleitem.hxx> +#include <charreliefitem.hxx> +#include <frmdiritem.hxx> +#include <xmlcnitm.hxx> + + + +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { + +/*N*/ GlobalEditData::GlobalEditData() +/*N*/ { +/*N*/ ppDefItems = NULL; +/*N*/ pStdRefDevice = NULL; +/*N*/ } + +/*N*/ GlobalEditData::~GlobalEditData() +/*N*/ { +/*N*/ // DefItems zerstoeren... +/*N*/ // Oder einfach stehen lassen, da sowieso App-Ende?! +/*N*/ if ( ppDefItems ) +/*N*/ SfxItemPool::ReleaseDefaults( ppDefItems, EDITITEMCOUNT, TRUE ); +/*N*/ delete pStdRefDevice; +/*N*/ } + +/*N*/ SfxPoolItem** GlobalEditData::GetDefItems() +/*N*/ { +/*N*/ if ( !ppDefItems ) +/*N*/ { +/*N*/ ppDefItems = new SfxPoolItem*[EDITITEMCOUNT]; +/*N*/ +/*N*/ // Absatzattribute: +/*N*/ SvxNumRule aTmpNumRule( 0, 0, FALSE ); +/*N*/ +/*N*/ ppDefItems[0] = new SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ); +/*N*/ #ifndef SVX_LIGHT +/*N*/ ppDefItems[1] = new SvXMLAttrContainerItem( EE_PARA_XMLATTRIBS ); +/*N*/ #else +/*N*/ ppDefItems[1] = new SfxVoidItem( EE_PARA_XMLATTRIBS ); +/*N*/ #endif // #ifndef SVX_LIGHT +/*N*/ ppDefItems[2] = new SfxBoolItem( EE_PARA_HANGINGPUNCTUATION, FALSE ); +/*N*/ ppDefItems[3] = new SfxBoolItem( EE_PARA_FORBIDDENRULES, TRUE ); +/*N*/ ppDefItems[4] = new SvxScriptSpaceItem( TRUE, EE_PARA_ASIANCJKSPACING ); +/*N*/ ppDefItems[5] = new SvxNumBulletItem( aTmpNumRule, EE_PARA_NUMBULLET ); +/*N*/ ppDefItems[6] = new SfxBoolItem( EE_PARA_HYPHENATE, FALSE ); +/*N*/ ppDefItems[7] = new SfxUInt16Item( EE_PARA_BULLETSTATE, 0 ); +/*N*/ ppDefItems[8] = new SvxLRSpaceItem( EE_PARA_OUTLLRSPACE ); +/*N*/ ppDefItems[9] = new SfxUInt16Item( EE_PARA_OUTLLEVEL ); +/*N*/ ppDefItems[10] = new SvxBulletItem( EE_PARA_BULLET ); +/*N*/ ppDefItems[11] = new SvxLRSpaceItem( EE_PARA_LRSPACE ); +/*N*/ ppDefItems[12] = new SvxULSpaceItem( EE_PARA_ULSPACE ); +/*N*/ ppDefItems[13] = new SvxLineSpacingItem( 0, EE_PARA_SBL ); +/*N*/ ppDefItems[14] = new SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ); +/*N*/ ppDefItems[15] = new SvxTabStopItem( 0, 0, SVX_TAB_ADJUST_LEFT, EE_PARA_TABS ); +/*N*/ +/*N*/ // Zeichenattribute: +/*N*/ ppDefItems[16] = new SvxColorItem( Color( COL_AUTO ), EE_CHAR_COLOR ); +/*N*/ ppDefItems[17] = new SvxFontItem( EE_CHAR_FONTINFO ); +/*N*/ ppDefItems[18] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT ); +/*N*/ ppDefItems[19] = new SvxCharScaleWidthItem( 100, EE_CHAR_FONTWIDTH ); +/*N*/ ppDefItems[20] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT ); +/*N*/ ppDefItems[21] = new SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ); +/*N*/ ppDefItems[22] = new SvxCrossedOutItem( STRIKEOUT_NONE, EE_CHAR_STRIKEOUT ); +/*N*/ ppDefItems[23] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC ); +/*N*/ ppDefItems[24] = new SvxContourItem( FALSE, EE_CHAR_OUTLINE ); +/*N*/ ppDefItems[25] = new SvxShadowedItem( FALSE, EE_CHAR_SHADOW ); +/*N*/ ppDefItems[26] = new SvxEscapementItem( 0, 100, EE_CHAR_ESCAPEMENT ); +/*N*/ ppDefItems[27] = new SvxAutoKernItem( FALSE, EE_CHAR_PAIRKERNING ); +/*N*/ ppDefItems[28] = new SvxKerningItem( 0, EE_CHAR_KERNING ); +/*N*/ ppDefItems[29] = new SvxWordLineModeItem( FALSE, EE_CHAR_WLM ); +/*N*/ ppDefItems[30] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE ); +/*N*/ ppDefItems[31] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CJK ); +/*N*/ ppDefItems[32] = new SvxLanguageItem( LANGUAGE_DONTKNOW, EE_CHAR_LANGUAGE_CTL ); +/*N*/ ppDefItems[33] = new SvxFontItem( EE_CHAR_FONTINFO_CJK ); +/*N*/ ppDefItems[34] = new SvxFontItem( EE_CHAR_FONTINFO_CTL ); +/*N*/ ppDefItems[35] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CJK ); +/*N*/ ppDefItems[36] = new SvxFontHeightItem( 240, 100, EE_CHAR_FONTHEIGHT_CTL ); +/*N*/ ppDefItems[37] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CJK ); +/*N*/ ppDefItems[38] = new SvxWeightItem( WEIGHT_NORMAL, EE_CHAR_WEIGHT_CTL ); +/*N*/ ppDefItems[39] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CJK ); +/*N*/ ppDefItems[40] = new SvxPostureItem( ITALIC_NONE, EE_CHAR_ITALIC_CTL ); +/*N*/ ppDefItems[41] = new SvxEmphasisMarkItem( EMPHASISMARK_NONE, EE_CHAR_EMPHASISMARK ); +/*N*/ ppDefItems[42] = new SvxCharReliefItem( RELIEF_NONE, EE_CHAR_RELIEF ); +/*N*/ ppDefItems[43] = new SfxVoidItem( EE_CHAR_RUBI_DUMMY ); +/*N*/ #ifndef SVX_LIGHT +/*N*/ ppDefItems[44] = new SvXMLAttrContainerItem( EE_CHAR_XMLATTRIBS ); +/*N*/ #else +/*N*/ // no need to have alien attributes persistent +/*N*/ ppDefItems[44] = new SfxVoidItem( EE_CHAR_XMLATTRIBS ); +/*N*/ #endif // #ifndef SVX_LIGHT +/*N*/ +/*N*/ // Features +/*N*/ ppDefItems[45] = new SfxVoidItem( EE_FEATURE_TAB ); +/*N*/ ppDefItems[46] = new SfxVoidItem( EE_FEATURE_LINEBR ); +/*N*/ ppDefItems[47] = new SvxCharSetColorItem( Color( COL_RED ), RTL_TEXTENCODING_DONTKNOW, EE_FEATURE_NOTCONV ); +/*N*/ ppDefItems[48] = new SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD ); +/*N*/ +/*N*/ DBG_ASSERT( EDITITEMCOUNT == 49, "ITEMCOUNT geaendert, DefItems nicht angepasst!" ); +/*N*/ +/*N*/ // Init DefFonts: +/*N*/ GetDefaultFonts( *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO - EE_ITEMS_START], +/*N*/ *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CJK - EE_ITEMS_START], +/*N*/ *(SvxFontItem*)ppDefItems[EE_CHAR_FONTINFO_CTL - EE_ITEMS_START] ); +/*N*/ } +/*N*/ +/*N*/ return ppDefItems; +/*N*/ } + +/*N*/ rtl::Reference<SvxForbiddenCharactersTable> GlobalEditData::GetForbiddenCharsTable() +/*N*/ { +/*N*/ if ( !xForbiddenCharsTable.is() ) +/*N*/ { +/*N*/ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF = ::legacy_binfilters::getLegacyProcessServiceFactory(); +/*N*/ xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF ); +/*N*/ } +/*N*/ return xForbiddenCharsTable; +/*N*/ } + + +/*N*/ OutputDevice* GlobalEditData::GetStdRefDevice() +/*N*/ { +/*N*/ if ( !pStdRefDevice ) +/*N*/ { +/*N*/ pStdRefDevice = new VirtualDevice; +/*N*/ pStdRefDevice->SetMapMode( MAP_TWIP ); +/*N*/ } +/*N*/ return pStdRefDevice; +/*N*/ } + +/*N*/ EditResId::EditResId( USHORT nId ): +/*N*/ ResId( nId, *EE_DLL()->GetResMgr() ) +/*N*/ { +/*N*/ } + +/*N*/ EditDLL::EditDLL() +/*N*/ { +/*N*/ pGlobalData = new GlobalEditData; +/*N*/ DBG_ASSERT( !*(EditDLL**)GetAppData(BF_SHL_EDIT), "Noch eine EditDLL ?!" ); +/*N*/ *(EditDLL**)GetAppData(BF_SHL_EDIT) = this; +/*N*/ +/*N*/ #ifndef SVX_LIGHT +/*N*/ ByteString aResMgrName( "bf_svx" ); //STRIP005 +/*N*/ #else +/*N*/ ByteString aResMgrName( "bf_svl" ); //STRIP005 +/*N*/ #endif +/*N*/ pResMgr = ResMgr::CreateResMgr( +/*N*/ aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); +/*N*/ } + +/*N*/ EditDLL::~EditDLL() +/*N*/ { +/*N*/ delete pResMgr; +/*N*/ delete pGlobalData; +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_forbiddencharacterstable.cxx b/binfilter/bf_svx/source/editeng/svx_forbiddencharacterstable.cxx new file mode 100644 index 000000000000..943f34fb128c --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_forbiddencharacterstable.cxx @@ -0,0 +1,88 @@ +/* -*- 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. + * + ************************************************************************/ + +#include <forbiddencharacterstable.hxx> + +#include <unotools/localedatawrapper.hxx> +#include <unolingu.hxx> + +/*STRIP001*/#include <tools/debug.hxx> +namespace binfilter { +/*N*/ SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, USHORT nISize, USHORT nGrow ) +/*N*/ : SvxForbiddenCharactersTableImpl( nISize, nGrow ) +/*N*/ { +/*N*/ mxMSF = xMSF; +/*N*/ } + + +/*N*/ SvxForbiddenCharactersTable::~SvxForbiddenCharactersTable() +/*N*/ { +/*N*/ for ( ULONG n = Count(); n; ) +/*N*/ delete GetObject( --n ); +/*N*/ } + + + +const ::com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( USHORT nLanguage, BOOL bGetDefault ) const +{ + ForbiddenCharactersInfo* pInf = Get( nLanguage ); + if ( !pInf && bGetDefault && mxMSF.is() ) + { + const SvxForbiddenCharactersTableImpl *pConstImpl = + dynamic_cast<const SvxForbiddenCharactersTableImpl*>(this); + SvxForbiddenCharactersTableImpl* pImpl = + const_cast<SvxForbiddenCharactersTableImpl*>(pConstImpl); + pInf = new ForbiddenCharactersInfo; + pImpl->Insert( nLanguage, pInf ); + pInf->bTemporary = TRUE; + LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) ); + pInf->aForbiddenChars = aWrapper.getForbiddenCharacters(); + } + return pInf ? &pInf->aForbiddenChars : NULL; +} + + + +/*N*/ void SvxForbiddenCharactersTable::SetForbiddenCharacters( USHORT nLanguage, const ::com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars ) +/*N*/ { +/*N*/ ForbiddenCharactersInfo* pInf = Get( nLanguage ); +/*N*/ if ( !pInf ) +/*N*/ { +/*N*/ pInf = new ForbiddenCharactersInfo; +/*N*/ Insert( nLanguage, pInf ); +/*N*/ } +/*N*/ pInf->bTemporary = FALSE; +/*N*/ pInf->aForbiddenChars = rForbiddenChars; +/*N*/ } + +/*N*/ void SvxForbiddenCharactersTable::ClearForbiddenCharacters( USHORT nLanguage ) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_impedit.cxx b/binfilter/bf_svx/source/editeng/svx_impedit.cxx new file mode 100644 index 000000000000..2740a029bb07 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_impedit.cxx @@ -0,0 +1,259 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> + + + + + + + + + + + +#include "itemdata.hxx" + + + +#include <flditem.hxx> + +namespace binfilter { + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::linguistic2; + +#define SCRLRANGE 20 // 1/20 der Breite/Hoehe scrollen, wenn im QueryDrop + + +/*N*/ ImpEditView::~ImpEditView() +/*N*/ { +/*N*/ if ( pOutWin && ( pOutWin->GetCursor() == pCursor ) ) +/*N*/ pOutWin->SetCursor( NULL ); +/*N*/ +/*N*/ delete pCursor; +/*N*/ delete pBackgroundColor; +/*N*/ delete pPointer; +/*N*/ } + + +/*N*/ void ImpEditView::SetEditSelection( const EditSelection& rEditSelection ) +/*N*/ { +/*N*/ // #100856# set state before notification +/*N*/ aEditSelection = rEditSelection; +/*N*/ +/*N*/ if ( pEditEngine->pImpEditEngine->GetNotifyHdl().IsSet() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EENotify aNotify( EE_NOTIFY_TEXTVIEWSELECTIONCHANGED ); +/*N*/ } +/*N*/ } + + +/*N*/ void ImpEditView::DrawSelection( EditSelection aTmpSel, Region* pRegion ) +/*N*/ { +/*N*/ // Vor dem Zeichnen der Selektion muss sichergestellt werden, +/*N*/ // das der Fensterinhalt komplett gueltig ist! +/*N*/ // Muss hier stehen, damit auf jeden Fall weg wenn lerr, nicht spaeter +/*N*/ // zwei Paint-Events! +/*N*/ // 19.10: Muss sogar vor Abfrage von bUpdate, falls nach Invalidate +/*N*/ // noch Paints in der Queue, aber jemand schaltet den UpdateMode um! +/*N*/ +/*N*/ // pRegion: Wenn nicht NULL, dann nur Region berechnen. +/*N*/ PolyPolygon* pPolyPoly = NULL; +/*N*/ if ( pRegion ) +/*?*/ pPolyPoly = new PolyPolygon; +/*N*/ +/*N*/ sal_Bool bClipRegion = pOutWin->IsClipRegion(); +/*N*/ Region aOldRegion = pOutWin->GetClipRegion(); +/*N*/ +/*N*/ if ( !pRegion ) +/*N*/ { +/*N*/ if ( pEditEngine->pImpEditEngine->GetUpdateMode() == sal_False ) +/*N*/ return; +/*N*/ if ( pEditEngine->pImpEditEngine->IsInUndo() ) +/*N*/ return; +/*N*/ +/*N*/ if ( !aTmpSel.HasRange() ) +/*N*/ return; +/*N*/ +/*?*/ // aTmpOutArea: Falls OutputArea > Papierbreite und +/*?*/ // Text > Papierbreite ( uebergrosse Felder ) +/*?*/ Rectangle aTmpOutArea( aOutArea ); +/*?*/ if ( aTmpOutArea.GetWidth() > pEditEngine->pImpEditEngine->GetPaperSize().Width() ) +/*?*/ aTmpOutArea.Right() = aTmpOutArea.Left() + pEditEngine->pImpEditEngine->GetPaperSize().Width(); +/*?*/ pOutWin->IntersectClipRegion( aTmpOutArea ); +/*?*/ +/*?*/ if ( pOutWin->GetCursor() ) +/*?*/ pOutWin->GetCursor()->Hide(); +/*?*/ } +/*?*/ +/*?*/ aTmpSel.Adjust( pEditEngine->pImpEditEngine->GetEditDoc() ); +/*?*/ +/*?*/ ContentNode* pStartNode = aTmpSel.Min().GetNode(); +/*?*/ ContentNode* pEndNode = aTmpSel.Max().GetNode(); +/*?*/ sal_uInt16 nStartPara = pEditEngine->pImpEditEngine->GetEditDoc().GetPos( pStartNode ); +/*?*/ sal_uInt16 nEndPara = pEditEngine->pImpEditEngine->GetEditDoc().GetPos( pEndNode ); +/*?*/ // ueber die Absaetze iterieren.... +/*?*/ for ( sal_uInt16 nPara = nStartPara; nPara <= nEndPara; nPara++ ) +/*?*/ { +/*?*/ ParaPortion* pTmpPortion = pEditEngine->pImpEditEngine->GetParaPortions().SaveGetObject( nPara ); +/*?*/ DBG_ASSERT( pTmpPortion, "Portion in Selektion nicht gefunden!" ); +/*?*/ DBG_ASSERT( !pTmpPortion->IsInvalid(), "Portion in Selektion nicht formatiert!" ); +/*?*/ +/*?*/ if ( !pTmpPortion->IsVisible() || pTmpPortion->IsInvalid() ) +/*?*/ continue; +/*?*/ +/*?*/ long nParaStart = pEditEngine->pImpEditEngine->GetParaPortions().GetYOffset( pTmpPortion ); +/*?*/ if ( ( nParaStart + pTmpPortion->GetHeight() ) < GetVisDocTop() ) +/*?*/ continue; +/*?*/ if ( nParaStart > GetVisDocBottom() ) +/*?*/ break; +/*?*/ +/*?*/ sal_uInt16 nStartLine = 0; +/*?*/ sal_uInt16 nEndLine = pTmpPortion->GetLines().Count() -1; +/*?*/ if ( nPara == nStartPara ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 nStartLine = pTmpPortion->GetLines().FindLine( aTmpSel.Min().GetIndex(), sal_False ); +/*?*/ if ( nPara == nEndPara ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 nEndLine = pTmpPortion->GetLines().FindLine( aTmpSel.Max().GetIndex(), sal_True ); +/*?*/ +/*?*/ // ueber die Zeilen iterieren.... +/*?*/ for ( sal_uInt16 nLine = nStartLine; nLine <= nEndLine; nLine++ ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditLine* pLine = pTmpPortion->GetLines().GetObject( nLine ); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ if ( pRegion ) +/*?*/ { +/*?*/ *pRegion = Region( *pPolyPoly ); +/*?*/ delete pPolyPoly; +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ if ( pOutWin->GetCursor() ) +/*?*/ pOutWin->GetCursor()->Show(); +/*?*/ +/*?*/ if ( bClipRegion ) +/*?*/ pOutWin->SetClipRegion( aOldRegion ); +/*?*/ else +/*?*/ pOutWin->SetClipRegion(); +/*?*/ } +/*N*/ } + + + +/*N*/ BOOL ImpEditView::IsVertical() const +/*N*/ { +/*N*/ return pEditEngine->pImpEditEngine->IsVertical(); +/*N*/ } + +/*N*/ Rectangle ImpEditView::GetVisDocArea() const +/*N*/ { +/*N*/ return Rectangle( GetVisDocLeft(), GetVisDocTop(), GetVisDocRight(), GetVisDocBottom() ); +/*N*/ } + +/*N*/ Point ImpEditView::GetDocPos( const Point& rWindowPos ) const +/*N*/ { +/*N*/ // Fensterposition => Dokumentposition +/*N*/ Point aPoint; +/*N*/ +/*N*/ if ( !pEditEngine->pImpEditEngine->IsVertical() ) +/*N*/ { +/*N*/ aPoint.X() = rWindowPos.X() - aOutArea.Left() + GetVisDocLeft(); +/*N*/ aPoint.Y() = rWindowPos.Y() - aOutArea.Top() + GetVisDocTop(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aPoint.X() = rWindowPos.Y() - aOutArea.Top() + GetVisDocLeft(); +/*?*/ aPoint.Y() = aOutArea.Right() - rWindowPos.X() + GetVisDocTop(); +/*N*/ } +/*N*/ +/*N*/ return aPoint; +/*N*/ } + +/*N*/ Point ImpEditView::GetWindowPos( const Point& rDocPos ) const +/*N*/ { +/*N*/ // Dokumentposition => Fensterposition +/*N*/ Point aPoint; +/*N*/ +/*N*/ if ( !pEditEngine->pImpEditEngine->IsVertical() ) +/*N*/ { +/*N*/ aPoint.X() = rDocPos.X() + aOutArea.Left() - GetVisDocLeft(); +/*N*/ aPoint.Y() = rDocPos.Y() + aOutArea.Top() - GetVisDocTop(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aPoint.X() = aOutArea.Right() - rDocPos.Y() + GetVisDocTop(); +/*?*/ aPoint.Y() = rDocPos.X() + aOutArea.Top() - GetVisDocLeft(); +/*N*/ } +/*N*/ +/*N*/ return aPoint; +/*N*/ } + +/*N*/ Rectangle ImpEditView::GetWindowPos( const Rectangle& rDocRect ) const +/*N*/ { +/*N*/ // Dokumentposition => Fensterposition +/*N*/ Point aPos( GetWindowPos( rDocRect.TopLeft() ) ); +/*N*/ Size aSz = rDocRect.GetSize(); +/*N*/ Rectangle aRect; +/*N*/ if ( !pEditEngine->pImpEditEngine->IsVertical() ) +/*N*/ { +/*N*/ aRect = Rectangle( aPos, aSz ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ Point aNewPos( aPos.X()-aSz.Height(), aPos.Y() ); +/*?*/ aRect = Rectangle( aNewPos, Size( aSz.Height(), aSz.Width() ) ); +/*N*/ } +/*N*/ return aRect; +/*N*/ } + +/*N*/ void ImpEditView::ShowCursor( sal_Bool bGotoCursor, sal_Bool bForceVisCursor, USHORT nShowCursorFlags ) +/*N*/ { +/*N*/ // Kein ShowCursor bei einer leeren View... +/*N*/ if ( ( aOutArea.Left() >= aOutArea.Right() ) && ( aOutArea.Top() >= aOutArea.Bottom() ) ) +/*N*/ return; +/*N*/ +/*?*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_impedit2.cxx b/binfilter/bf_svx/source/editeng/svx_impedit2.cxx new file mode 100644 index 000000000000..794864bfb27a --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_impedit2.cxx @@ -0,0 +1,2084 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitem.hxx" +#include "eeitemid.hxx" + +#include <lspcitem.hxx> + + + +#include "itemdata.hxx" + +#include <tools/date.hxx> + +#include <tools/time.hxx> + + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> +#include <editview.hxx> +#include <eerdll2.hxx> +#include <eerdll.hxx> +#include <txtrange.hxx> +#include <bf_svtools/colorcfg.hxx> +#include <bf_svtools/ctloptions.hxx> + +#include <lrspitem.hxx> +#include <ulspitem.hxx> +#include <adjitem.hxx> +#include <scripttypeitem.hxx> +#include <frmdiritem.hxx> + + + + +#include <vcl/cmdevt.h> + +#ifndef SVX_LIGHT +#endif + + + +#include <com/sun/star/i18n/ScriptType.hpp> + +#include <com/sun/star/text/CharacterCompressionType.hpp> + + + +#include <unicode/ubidi.h> +namespace binfilter { + +#if defined(MACOSX) && ( __GNUC__ < 3 ) +// moved from editundo.hxx +const EPaM& EditUndoRemoveChars::GetEPaM() { return aEPaM; } +String& EditUndoRemoveChars::GetStr() { return aText; } +#endif + +using namespace ::com::sun::star; + +/*N*/ USHORT lcl_CalcExtraSpace( ParaPortion* pPortion, const SvxLineSpacingItem& rLSItem ) +/*N*/ { +/*N*/ USHORT nExtra = 0; + /* if ( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) + && ( rLSItem.GetPropLineSpace() != 100 ) ) + { + // ULONG nH = pPortion->GetNode()->GetCharAttribs().GetDefFont().GetSize().Height(); + ULONG nH = pPortion->GetLines().GetObject( 0 )->GetHeight(); + long n = nH * rLSItem.GetPropLineSpace(); + n /= 100; + n -= nH; // nur den Abstand + if ( n > 0 ) + nExtra = (USHORT)n; + } + else */ +/*N*/ if ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) +/*N*/ { +/*?*/ nExtra = rLSItem.GetInterLineSpace(); +/*N*/ } +/*N*/ +/*N*/ return nExtra; +/*N*/ } + +// ---------------------------------------------------------------------- +// class ImpEditEngine +// ---------------------------------------------------------------------- + +/*N*/ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : +/*N*/ aEditDoc( pItemPool ), +/*N*/ aPaperSize( 0x7FFFFFFF, 0x7FFFFFFF ), +/*N*/ aMaxAutoPaperSize( 0x7FFFFFFF, 0x7FFFFFFF ), +/*N*/ aMinAutoPaperSize( 0x0, 0x0 ), +/*N*/ aGroupChars( RTL_CONSTASCII_USTRINGPARAM( "{}()[]" ) ), +/*N*/ aWordDelimiters( RTL_CONSTASCII_USTRINGPARAM( " .,;:-'`'?!_=\"{}()[]\0xFF" ) ) +/*N*/ { +/*N*/ pEditEngine = pEE; +/*N*/ pRefDev = NULL; +/*N*/ pVirtDev = NULL; +/*N*/ pEmptyItemSet = NULL; +/*N*/ pActiveView = NULL; +/*N*/ pTextObjectPool = NULL; +/*N*/ mpIMEInfos = NULL; +/*N*/ pStylePool = NULL; +/*N*/ pUndoManager = NULL; +/*N*/ pUndoMarkSelection = NULL; +/*N*/ pTextRanger = NULL; +/*N*/ pColorConfig = NULL; +/*N*/ pCTLOptions = NULL; +/*N*/ +/*N*/ nCurTextHeight = 0; +/*N*/ nBlockNotifications = 0; +/*N*/ nBigTextObjectStart = 20; +/*N*/ +/*N*/ nStretchX = 100; +/*N*/ nStretchY = 100; +/*N*/ +/*N*/ bInSelection = FALSE; +/*N*/ bOwnerOfRefDev = FALSE; +/*N*/ bDowning = FALSE; +/*N*/ bIsInUndo = FALSE; +/*N*/ bIsFormatting = FALSE; +/*N*/ bFormatted = FALSE; +/*N*/ bUpdate = TRUE; +/*N*/ bUseAutoColor = TRUE; +/*N*/ bForceAutoColor = FALSE; +/*N*/ #ifndef SVX_LIGHT +/*N*/ bUndoEnabled = TRUE; +/*N*/ #else +/*N*/ bUndoEnabled = FALSE; +/*N*/ #endif +/*N*/ bCallParaInsertedOrDeleted = FALSE; +/*N*/ +/*N*/ eDefLanguage = LANGUAGE_DONTKNOW; +/*N*/ maBackgroundColor = COL_AUTO; +/*N*/ +/*N*/ nAsianCompressionMode = text::CharacterCompressionType::NONE; +/*N*/ bKernAsianPunctuation = FALSE; +/*N*/ +/*N*/ eDefaultHorizontalTextDirection = EE_HTEXTDIR_DEFAULT; +/*N*/ +/*N*/ +/*N*/ aStatus.GetControlWord() = EE_CNTRL_USECHARATTRIBS | EE_CNTRL_DOIDLEFORMAT | +/*N*/ EE_CNTRL_PASTESPECIAL | EE_CNTRL_UNDOATTRIBS | +/*N*/ EE_CNTRL_ALLOWBIGOBJS | EE_CNTRL_RTFSTYLESHEETS | +/*N*/ EE_CNTRL_FORMAT100; +/*N*/ +/*N*/ aSelEngine.SetFunctionSet( &aSelFuncSet ); +/*N*/ +/*N*/ pRefDev = EE_DLL()->GetGlobalData()->GetStdRefDevice(); +/*N*/ +/*N*/ // Ab hier wird schon auf Daten zugegriffen! +/*N*/ SetRefDevice( pRefDev ); +/*N*/ InitDoc( FALSE ); +/*N*/ +/*N*/ bCallParaInsertedOrDeleted = TRUE; +/*N*/ +/*N*/ } + +/*N*/ ImpEditEngine::~ImpEditEngine() +/*N*/ { +/*N*/ // das Zerstoeren von Vorlagen kann sonst unnoetiges Formatieren ausloesen, +/*N*/ // wenn eine Parent-Vorlage zerstoert wird. +/*N*/ // Und das nach dem Zerstoeren der Daten! +/*N*/ bDowning = TRUE; +/*N*/ SetUpdateMode( FALSE ); +/*N*/ +/*N*/ delete pVirtDev; +/*N*/ delete pEmptyItemSet; +/*N*/ delete pUndoManager; +/*N*/ delete pTextRanger; +/*N*/ delete mpIMEInfos; +/*N*/ delete pColorConfig; +/*N*/ delete pCTLOptions; +/*N*/ if ( bOwnerOfRefDev ) +/*N*/ delete pRefDev; +/*N*/ } + +/*N*/ void ImpEditEngine::SetRefDevice( OutputDevice* pRef ) +/*N*/ { +/*N*/ if ( bOwnerOfRefDev ) +/*N*/ delete pRefDev; +/*N*/ +/*N*/ pRefDev = pRef; +/*N*/ bOwnerOfRefDev = FALSE; +/*N*/ +/*N*/ if ( !pRef ) +/*N*/ pRefDev = EE_DLL()->GetGlobalData()->GetStdRefDevice(); +/*N*/ +/*N*/ nOnePixelInRef = (USHORT)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width(); +/*N*/ +/*N*/ if ( IsFormatted() ) +/*N*/ { +/*N*/ FormatFullDoc(); +/*N*/ UpdateViews( (EditView*) 0); +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::SetRefMapMode( const MapMode& rMapMode ) +/*N*/ { +/*N*/ if ( GetRefDevice()->GetMapMode() == rMapMode ) +/*N*/ return; +/*N*/ +/*N*/ // Wenn RefDev == GlobalRefDev => eigenes anlegen! +/*N*/ if ( !bOwnerOfRefDev && ( pRefDev == EE_DLL()->GetGlobalData()->GetStdRefDevice() ) ) +/*N*/ { +/*N*/ pRefDev = new VirtualDevice; +/*N*/ pRefDev->SetMapMode( MAP_TWIP ); +/*N*/ SetRefDevice( pRefDev ); +/*N*/ bOwnerOfRefDev = TRUE; +/*N*/ } +/*N*/ pRefDev->SetMapMode( rMapMode ); +/*N*/ nOnePixelInRef = (USHORT)pRefDev->PixelToLogic( Size( 1, 0 ) ).Width(); +/*N*/ if ( IsFormatted() ) +/*N*/ { +/*N*/ FormatFullDoc(); +/*N*/ UpdateViews( (EditView*) 0); +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::InitDoc( BOOL bKeepParaAttribs ) +/*N*/ { +/*N*/ USHORT nParas = aEditDoc.Count(); +/*N*/ for ( USHORT n = bKeepParaAttribs ? 1 : 0; n < nParas; n++ ) +/*N*/ { +/*N*/ if ( aEditDoc[n]->GetStyleSheet() ) +/*N*/ EndListening( *aEditDoc[n]->GetStyleSheet(), FALSE ); +/*N*/ } +/*N*/ +/*N*/ if ( bKeepParaAttribs ) +/*N*/ aEditDoc.RemoveText(); +/*N*/ else +/*N*/ aEditDoc.Clear(); +/*N*/ +/*N*/ GetParaPortions().Reset(); +/*N*/ +/*N*/ ParaPortion* pIniPortion = new ParaPortion( aEditDoc[0] ); +/*N*/ GetParaPortions().Insert( pIniPortion, 0 ); +/*N*/ +/*N*/ bFormatted = FALSE; +/*N*/ +/*N*/ if ( IsCallParaInsertedOrDeleted() ) +/*N*/ { +/*N*/ GetEditEnginePtr()->ParagraphDeleted( EE_PARA_ALL ); +/*N*/ GetEditEnginePtr()->ParagraphInserted( 0 ); +/*N*/ } +/*N*/ } + + +/*N*/ XubString ImpEditEngine::GetSelected( const EditSelection& rSel, const LineEnd eEnd ) const +/*N*/ { +/*N*/ XubString aText; +/*N*/ if ( !rSel.HasRange() ) +/*N*/ return aText; +/*N*/ +/*N*/ String aSep = EditDoc::GetSepStr( eEnd ); +/*N*/ +/*N*/ EditSelection aSel( rSel ); +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ +/*N*/ ContentNode* pStartNode = aSel.Min().GetNode(); +/*N*/ ContentNode* pEndNode = aSel.Max().GetNode(); +/*N*/ USHORT nStartNode = aEditDoc.GetPos( pStartNode ); +/*N*/ USHORT nEndNode = aEditDoc.GetPos( pEndNode ); +/*N*/ +/*N*/ DBG_ASSERT( nStartNode <= nEndNode, "Selektion nicht sortiert ?" ); +/*N*/ +/*N*/ // ueber die Absaetze iterieren... +/*N*/ for ( USHORT nNode = nStartNode; nNode <= nEndNode; nNode++ ) +/*N*/ { +/*N*/ DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node nicht gefunden: GetSelected" ); +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nNode ); +/*N*/ +/*N*/ xub_StrLen nStartPos = 0; +/*N*/ xub_StrLen nEndPos = pNode->Len(); +/*N*/ if ( nNode == nStartNode ) +/*N*/ nStartPos = aSel.Min().GetIndex(); +/*N*/ if ( nNode == nEndNode ) // kann auch == nStart sein! +/*N*/ nEndPos = aSel.Max().GetIndex(); +/*N*/ +/*N*/ aText += aEditDoc.GetParaAsString( pNode, nStartPos, nEndPos ); +/*N*/ if ( nNode < nEndNode ) +/*N*/ aText += aSep; +/*N*/ } +/*N*/ return aText; +/*N*/ } + + + + + + +/*N*/ EditPaM ImpEditEngine::Clear() +/*N*/ { +/*N*/ InitDoc( FALSE ); +/*N*/ +/*N*/ EditPaM aPaM = aEditDoc.GetStartPaM(); +/*N*/ EditSelection aSel( aPaM ); +/*N*/ +/*N*/ nCurTextHeight = 0; +/*N*/ +/*N*/ ResetUndoManager(); +/*N*/ +/*N*/ for ( USHORT nView = aEditViews.Count(); nView; ) +/*N*/ { +/*?*/ EditView* pView = aEditViews[--nView]; +/*?*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*?*/ pView->pImpEditView->SetEditSelection( aSel ); +/*N*/ } +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::RemoveText() +/*N*/ { +/*N*/ InitDoc( TRUE ); +/*N*/ +/*N*/ EditPaM aStartPaM = aEditDoc.GetStartPaM(); +/*N*/ EditSelection aEmptySel( aStartPaM, aStartPaM ); +/*N*/ for ( USHORT nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*N*/ EditView* pView = aEditViews.GetObject(nView); +/*N*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ pView->pImpEditView->SetEditSelection( aEmptySel ); +/*N*/ } +/*N*/ ResetUndoManager(); +/*N*/ return aEditDoc.GetStartPaM(); +/*N*/ } + + +/*N*/ void ImpEditEngine::SetText( const XubString& rText ) +/*N*/ { +/*N*/ // RemoveText loescht die Undo-Liste! +/*N*/ EditPaM aStartPaM = RemoveText(); +/*N*/ BOOL bUndoCurrentlyEnabled = IsUndoEnabled(); +/*N*/ // Der von Hand reingesteckte Text kann nicht vom Anwender rueckgaengig gemacht werden. +/*N*/ EnableUndo( FALSE ); +/*N*/ +/*N*/ EditSelection aEmptySel( aStartPaM, aStartPaM ); +/*N*/ EditPaM aPaM = aStartPaM; +/*N*/ if ( rText.Len() ) +/*N*/ aPaM = ImpInsertText( aEmptySel, rText ); +/*N*/ +/*N*/ for ( USHORT nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*N*/ EditView* pView = aEditViews[nView]; +/*N*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ pView->pImpEditView->SetEditSelection( EditSelection( aPaM, aPaM ) ); +/*N*/ // Wenn kein Text, dann auch Kein Format&Update +/*N*/ // => Der Text bleibt stehen. +/*N*/ if ( !rText.Len() && GetUpdateMode() ) +/*N*/ { +/*?*/ Rectangle aTmpRec( pView->GetOutputArea().TopLeft(), +/*?*/ Size( aPaperSize.Width(), nCurTextHeight ) ); +/*?*/ aTmpRec.Intersection( pView->GetOutputArea() ); +/*?*/ pView->GetWindow()->Invalidate( aTmpRec ); +/*N*/ } +/*N*/ } +/*N*/ if( !rText.Len() ) // sonst muss spaeter noch invalidiert werden, !bFormatted reicht. +/*N*/ nCurTextHeight = 0; +/*N*/ EnableUndo( bUndoCurrentlyEnabled ); +/*N*/ #ifndef SVX_LIGHT +/*N*/ DBG_ASSERT( !HasUndoManager() || !GetUndoManager().GetUndoActionCount(), "Undo nach SetText?" ); +/*N*/ #endif +/*N*/ } + + +/*N*/ const SfxItemSet& ImpEditEngine::GetEmptyItemSet() +/*N*/ { +/*N*/ if ( !pEmptyItemSet ) +/*N*/ { +/*N*/ pEmptyItemSet = new SfxItemSet( aEditDoc.GetItemPool(), EE_ITEMS_START, EE_ITEMS_END ); +/*N*/ for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_CHAR_END; nWhich++) +/*N*/ { +/*N*/ pEmptyItemSet->ClearItem( nWhich ); +/*N*/ } +/*N*/ } +/*N*/ return *pEmptyItemSet; +/*N*/ } + +// ---------------------------------------------------------------------- +// MISC +// ---------------------------------------------------------------------- +/*N*/ void ImpEditEngine::CursorMoved( ContentNode* pPrevNode ) +/*N*/ { +/*N*/ // Leere Attribute loeschen, aber nur, wenn Absatz nicht leer! +/*N*/ if ( pPrevNode->GetCharAttribs().HasEmptyAttribs() && pPrevNode->Len() ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 pPrevNode->GetCharAttribs().DeleteEmptyAttribs( aEditDoc.GetItemPool() ); +/*N*/ } + +/*N*/ void ImpEditEngine::TextModified() +/*N*/ { +/*N*/ bFormatted = FALSE; +/*N*/ +/*N*/ if ( GetNotifyHdl().IsSet() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EENotify aNotify( EE_NOTIFY_TEXTMODIFIED ); +/*N*/ } +/*N*/ } + + +/*N*/ void ImpEditEngine::ParaAttribsChanged( ContentNode* pNode ) +/*N*/ { +/*N*/ DBG_ASSERT( pNode, "ParaAttribsChanged: Welcher?" ); +/*N*/ +/*N*/ aEditDoc.SetModified( TRUE ); +/*N*/ bFormatted = FALSE; +/*N*/ +/*N*/ ParaPortion* pPortion = FindParaPortion( pNode ); +/*N*/ DBG_ASSERT( pPortion, "ParaAttribsChanged: Portion?" ); +/*N*/ pPortion->MarkSelectionInvalid( 0, pNode->Len() ); +/*N*/ +/*N*/ USHORT nPara = aEditDoc.GetPos( pNode ); +/*N*/ pEditEngine->ParaAttribsChanged( nPara ); +/*N*/ +/*N*/ ParaPortion* pNextPortion = GetParaPortions().SaveGetObject( nPara+1 ); +/*N*/ // => wird sowieso noch formatiert, wenn Invalid. +/*N*/ if ( pNextPortion && !pNextPortion->IsInvalid() ) +/*?*/ CalcHeight( pNextPortion ); +/*N*/ } + +// ---------------------------------------------------------------------- +// Cursorbewegungen +// ---------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + +/*N*/ EditPaM ImpEditEngine::WordRight( const EditPaM& rPaM, sal_Int16 nWordType ) +/*N*/ { +/*N*/ xub_StrLen nMax = rPaM.GetNode()->Len(); +/*N*/ EditPaM aNewPaM( rPaM ); +/*N*/ if ( aNewPaM.GetIndex() < nMax ) +/*N*/ { +/*N*/ uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); +/*N*/ i18n::Boundary aBoundary = xBI->nextWord( *aNewPaM.GetNode(), aNewPaM.GetIndex(), GetLocale( aNewPaM ), nWordType ); +/*N*/ aNewPaM.SetIndex( (USHORT)aBoundary.startPos ); +/*N*/ } +/*N*/ // not 'else', maybe the index reached nMax now... +/*N*/ if ( aNewPaM.GetIndex() >= nMax ) +/*N*/ { +/*?*/ // Naechster Absatz... +/*?*/ USHORT nCurPara = aEditDoc.GetPos( aNewPaM.GetNode() ); +/*?*/ ContentNode* pNextNode = aEditDoc.SaveGetObject( ++nCurPara ); +/*?*/ if ( pNextNode ) +/*?*/ { +/*?*/ aNewPaM.SetNode( pNextNode ); +/*?*/ aNewPaM.SetIndex( 0 ); +/*?*/ } +/*N*/ } +/*N*/ return aNewPaM; +/*N*/ } + + + +/*N*/ EditSelection ImpEditEngine::SelectWord( const EditSelection& rCurSel, sal_Int16 nWordType, BOOL bAcceptStartOfWord ) +/*N*/ { +/*N*/ EditSelection aNewSel( rCurSel ); +/*N*/ EditPaM aPaM( rCurSel.Max() ); +/*N*/ uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); +/*N*/ sal_Int16 nType = xBI->getWordType( *aPaM.GetNode(), aPaM.GetIndex(), GetLocale( aPaM ) ); +/*N*/ if ( nType == i18n::WordType::ANY_WORD ) +/*N*/ { +/*N*/ i18n::Boundary aBoundary = xBI->getWordBoundary( *aPaM.GetNode(), aPaM.GetIndex(), GetLocale( aPaM ), nWordType, sal_True ); +/*N*/ // don't select when curser at end of word +/*N*/ if ( ( aBoundary.endPos > aPaM.GetIndex() ) && +/*N*/ ( bAcceptStartOfWord || ( aBoundary.startPos < aPaM.GetIndex() ) ) ) +/*N*/ { +/*N*/ aNewSel.Min().SetIndex( (USHORT)aBoundary.startPos ); +/*N*/ aNewSel.Max().SetIndex( (USHORT)aBoundary.endPos ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return aNewSel; +/*N*/ } + +/*N*/ void ImpEditEngine::InitScriptTypes( USHORT nPara ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ rTypes.Remove( 0, rTypes.Count() ); +/*N*/ +/*N*/ +/*N*/ // pParaPortion->aExtraCharInfos.Remove( 0, pParaPortion->aExtraCharInfos.Count() ); +/*N*/ +/*N*/ ContentNode* pNode = pParaPortion->GetNode(); +/*N*/ if ( pNode->Len() ) +/*N*/ { +/*N*/ uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); +/*N*/ +/*N*/ String aText( *pNode ); +/*N*/ +/*N*/ // To handle fields put the character from the field in the string, +/*N*/ // because endOfScript( ... ) will skip the CH_FEATURE, because this is WEAK +/*N*/ EditCharAttrib* pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, 0 ); +/*N*/ while ( pField ) +/*N*/ { +/*N*/ ::rtl::OUString aFldText( ((EditCharAttribField*)pField)->GetFieldValue() ); +/*N*/ if ( aFldText.getLength() ) +/*N*/ { +/*N*/ aText.SetChar( pField->GetStart(), aFldText.getStr()[0] ); +/*N*/ short nFldScriptType = xBI->getScriptType( aFldText, 0 ); +/*N*/ +/*N*/ for ( USHORT nCharInField = 1; nCharInField < aFldText.getLength(); nCharInField++ ) +/*N*/ { +/*N*/ short nTmpType = xBI->getScriptType( aFldText, nCharInField ); +/*N*/ +/*N*/ // First char from field wins... +/*N*/ if ( nFldScriptType == i18n::ScriptType::WEAK ) +/*N*/ { +/*?*/ nFldScriptType = nTmpType; +/*?*/ aText.SetChar( pField->GetStart(), aFldText.getStr()[nCharInField] ); +/*N*/ } +/*N*/ +/*N*/ // ... but if the first one is LATIN, and there are CJK or CTL chars too, +/*N*/ // we prefer that ScripType because we need an other font. +/*N*/ if ( ( nTmpType == i18n::ScriptType::ASIAN ) || ( nTmpType == i18n::ScriptType::COMPLEX ) ) +/*N*/ { +/*?*/ aText.SetChar( pField->GetStart(), aFldText.getStr()[nCharInField] ); +/*?*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ pField = pNode->GetCharAttribs().FindNextAttrib( EE_FEATURE_FIELD, pField->GetEnd() ); +/*N*/ } +/*N*/ +/*N*/ ::rtl::OUString aOUText( aText ); +/*N*/ USHORT nTextLen = (USHORT)aOUText.getLength(); +/*N*/ +/*N*/ long nPos = 0; +/*N*/ short nScriptType = xBI->getScriptType( aOUText, nPos ); +/*N*/ rTypes.Insert( ScriptTypePosInfo( nScriptType, (USHORT)nPos, nTextLen ), rTypes.Count() ); +/*N*/ nPos = xBI->endOfScript( aOUText, nPos, nScriptType ); +/*N*/ while ( ( nPos != (-1) ) && ( nPos < nTextLen ) ) +/*N*/ { +/*N*/ rTypes[rTypes.Count()-1].nEndPos = (USHORT)nPos; +/*N*/ +/*N*/ nScriptType = xBI->getScriptType( aOUText, nPos ); +/*N*/ long nEndPos = xBI->endOfScript( aOUText, nPos, nScriptType ); +/*N*/ +/*N*/ // #96850# Handle blanks as weak, remove if BreakIterator returns WEAK for spaces. +/*N*/ if ( ( nScriptType == i18n::ScriptType::LATIN ) && ( aOUText.getStr()[ nPos ] == 0x20 ) ) +/*N*/ { +/*?*/ BOOL bOnlySpaces = TRUE; +/*?*/ for ( USHORT n = nPos+1; ( n < nEndPos ) && bOnlySpaces; n++ ) +/*?*/ { +/*?*/ if ( aOUText.getStr()[ n ] != 0x20 ) +/*?*/ bOnlySpaces = FALSE; +/*?*/ } +/*?*/ if ( bOnlySpaces ) +/*?*/ nScriptType = i18n::ScriptType::WEAK; +/*N*/ } +/*N*/ +/*N*/ if ( ( nScriptType == i18n::ScriptType::WEAK ) || ( nScriptType == rTypes[rTypes.Count()-1].nScriptType ) ) +/*N*/ { +/*?*/ // Expand last ScriptTypePosInfo, don't create weak or unecessary portions +/*?*/ rTypes[rTypes.Count()-1].nEndPos = (USHORT)nEndPos; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ rTypes.Insert( ScriptTypePosInfo( nScriptType, (USHORT)nPos, nTextLen ), rTypes.Count() ); +/*N*/ } +/*N*/ +/*N*/ nPos = nEndPos; +/*N*/ } +/*N*/ +/*N*/ if ( rTypes[0].nScriptType == i18n::ScriptType::WEAK ) +/*N*/ rTypes[0].nScriptType = ( rTypes.Count() > 1 ) ? rTypes[1].nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); +/*N*/ } +/*N*/ } + +/*N*/ USHORT ImpEditEngine::GetScriptType( const EditPaM& rPaM, USHORT* pEndPos ) const +/*N*/ { +/*N*/ USHORT nScriptType = 0; +/*N*/ +/*N*/ if ( pEndPos ) +/*?*/ *pEndPos = rPaM.GetNode()->Len(); +/*N*/ +/*N*/ if ( rPaM.GetNode()->Len() ) +/*N*/ { +/*N*/ USHORT nPara = GetEditDoc().GetPos( rPaM.GetNode() ); +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( !pParaPortion->aScriptInfos.Count() ) +/*?*/ ((ImpEditEngine*)this)->InitScriptTypes( nPara ); +/*N*/ +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ USHORT nPos = rPaM.GetIndex(); +/*N*/ for ( USHORT n = 0; n < rTypes.Count(); n++ ) +/*N*/ { +/*N*/ if ( ( rTypes[n].nStartPos <= nPos ) && ( rTypes[n].nEndPos >= nPos ) ) +/*N*/ { +/*N*/ nScriptType = rTypes[n].nScriptType; +/*N*/ if( pEndPos ) +/*?*/ *pEndPos = rTypes[n].nEndPos; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); +/*N*/ } + +/*N*/ USHORT ImpEditEngine::GetScriptType( const EditSelection& rSel ) const +/*N*/ { +/*N*/ EditSelection aSel( rSel ); +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ +/*N*/ short nScriptType = 0; +/*N*/ +/*N*/ USHORT nStartPara = GetEditDoc().GetPos( aSel.Min().GetNode() ); +/*N*/ USHORT nEndPara = GetEditDoc().GetPos( aSel.Max().GetNode() ); +/*N*/ +/*N*/ for ( USHORT nPara = nStartPara; nPara <= nEndPara; nPara++ ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( !pParaPortion->aScriptInfos.Count() ) +/*N*/ ((ImpEditEngine*)this)->InitScriptTypes( nPara ); +/*N*/ +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ +/*N*/ USHORT nS = ( nPara == nStartPara ) ? aSel.Min().GetIndex() : 0; +/*N*/ USHORT nE = ( nPara == nEndPara ) ? aSel.Max().GetIndex() : pParaPortion->GetNode()->Len(); +/*N*/ for ( USHORT n = 0; n < rTypes.Count(); n++ ) +/*N*/ { +/*N*/ if ( ( rTypes[n].nStartPos <= nE ) && ( rTypes[n].nEndPos >= nS ) ) +/*N*/ { +/*N*/ if ( rTypes[n].nScriptType != i18n::ScriptType::WEAK ) +/*N*/ { +/*N*/ nScriptType |= GetItemScriptType ( rTypes[n].nScriptType ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if ( !nScriptType && n ) +/*?*/ { +/*?*/ // #93548# When starting with WEAK, use prev ScriptType... +/*?*/ nScriptType = rTypes[n-1].nScriptType; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nScriptType ? nScriptType : GetI18NScriptTypeOfLanguage( GetDefaultLanguage() ); +/*N*/ } + +/*N*/ BOOL ImpEditEngine::IsScriptChange( const EditPaM& rPaM ) const +/*N*/ { +/*N*/ BOOL bScriptChange = FALSE; +/*N*/ +/*N*/ if ( rPaM.GetNode()->Len() ) +/*N*/ { +/*N*/ USHORT nPara = GetEditDoc().GetPos( rPaM.GetNode() ); +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( !pParaPortion->aScriptInfos.Count() ) +/*?*/ ((ImpEditEngine*)this)->InitScriptTypes( nPara ); +/*N*/ +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ USHORT nPos = rPaM.GetIndex(); +/*N*/ for ( USHORT n = 0; n < rTypes.Count(); n++ ) +/*N*/ { +/*N*/ if ( rTypes[n].nStartPos == nPos ) +/*N*/ { +/*N*/ bScriptChange = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return bScriptChange; +/*N*/ } + +/*N*/ BOOL ImpEditEngine::HasScriptType( USHORT nPara, USHORT nType ) const +/*N*/ { +/*N*/ BOOL bTypeFound = FALSE; +/*N*/ +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( !pParaPortion->aScriptInfos.Count() ) +/*N*/ ((ImpEditEngine*)this)->InitScriptTypes( nPara ); +/*N*/ +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ for ( USHORT n = rTypes.Count(); n && !bTypeFound; ) +/*N*/ { +/*N*/ if ( rTypes[--n].nScriptType == nType ) +/*N*/ bTypeFound = TRUE; +/*N*/ } +/*N*/ return bTypeFound; +/*N*/ } + +/*N*/ void ImpEditEngine::InitWritingDirections( USHORT nPara ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ WritingDirectionInfos& rInfos = pParaPortion->aWritingDirectionInfos; +/*N*/ rInfos.Remove( 0, rInfos.Count() ); +/*N*/ +/*N*/ BOOL bCTL = FALSE; +/*N*/ ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ for ( USHORT n = 0; n < rTypes.Count(); n++ ) +/*N*/ { +/*N*/ if ( rTypes[n].nScriptType == i18n::ScriptType::COMPLEX ) +/*N*/ { +/*N*/ bCTL = TRUE; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ const BYTE nDefaultDir = IsRightToLeft( nPara ) ? UBIDI_RTL : UBIDI_LTR; +/*N*/ if ( ( bCTL || ( nDefaultDir == UBIDI_RTL ) ) && pParaPortion->GetNode()->Len() ) +/*N*/ { +/*?*/ +/*?*/ String aText( *pParaPortion->GetNode() ); +/*?*/ +/*?*/ // +/*?*/ // Bidi functions from icu 2.0 +/*?*/ // +/*?*/ UErrorCode nError = U_ZERO_ERROR; +/*?*/ UBiDi* pBidi = ubidi_openSized( aText.Len(), 0, &nError ); +/*?*/ nError = U_ZERO_ERROR; +/*?*/ +/*?*/ ubidi_setPara( pBidi, reinterpret_cast<const UChar *>(aText.GetBuffer()), aText.Len(), nDefaultDir, NULL, &nError ); // UChar != sal_Unicode in MinGW +/*?*/ nError = U_ZERO_ERROR; +/*?*/ +/*?*/ long nCount = ubidi_countRuns( pBidi, &nError ); +/*?*/ +/*?*/ int32_t nStart = 0; +/*?*/ int32_t nEnd; +/*?*/ UBiDiLevel nCurrDir; +/*?*/ +/*?*/ for ( USHORT nIdx = 0; nIdx < nCount; ++nIdx ) +/*?*/ { +/*?*/ ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir ); +/*?*/ rInfos.Insert( WritingDirectionInfo( nCurrDir, (USHORT)nStart, (USHORT)nEnd ), rInfos.Count() ); +/*?*/ nStart = nEnd; +/*?*/ } +/*?*/ +/*?*/ ubidi_close( pBidi ); +/*N*/ } +/*N*/ +/*N*/ // No infos mean no CTL and default dir is L2R... +/*N*/ if ( !rInfos.Count() ) +/*N*/ rInfos.Insert( WritingDirectionInfo( 0, 0, (USHORT)pParaPortion->GetNode()->Len() ), rInfos.Count() ); +/*N*/ +/*N*/ } + +/*N*/ BOOL ImpEditEngine::IsRightToLeft( USHORT nPara ) const +/*N*/ { +/*N*/ BOOL bR2L = FALSE; +/*N*/ const SvxFrameDirectionItem* pFrameDirItem = NULL; +/*N*/ +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ bR2L = GetDefaultHorizontalTextDirection() == EE_HTEXTDIR_R2L; +/*N*/ pFrameDirItem = &(const SvxFrameDirectionItem&)GetParaAttrib( nPara, EE_PARA_WRITINGDIR ); +/*N*/ if ( pFrameDirItem->GetValue() == FRMDIR_ENVIRONMENT ) +/*N*/ { +/*N*/ // #103045# if DefaultHorizontalTextDirection is set, use that value, otherwise pool default. +/*N*/ if ( GetDefaultHorizontalTextDirection() != EE_HTEXTDIR_DEFAULT ) +/*N*/ { +/*?*/ pFrameDirItem = NULL; // bR2L allready set to default horizontal text direction +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Use pool default +/*N*/ pFrameDirItem = &(const SvxFrameDirectionItem&)((ImpEditEngine*)this)->GetEmptyItemSet().Get( EE_PARA_WRITINGDIR ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pFrameDirItem ) +/*N*/ bR2L = pFrameDirItem->GetValue() == FRMDIR_HORI_RIGHT_TOP; +/*N*/ +/*N*/ return bR2L; +/*N*/ } + + + +/*N*/ BYTE ImpEditEngine::GetRightToLeft( USHORT nPara, USHORT nPos, USHORT* pStart, USHORT* pEnd ) +/*N*/ { +/*N*/ // BYTE nRightToLeft = IsRightToLeft( nPara ) ? 1 : 0; +/*N*/ BYTE nRightToLeft = 0; +/*N*/ +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ if ( pNode && pNode->Len() ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ if ( !pParaPortion->aWritingDirectionInfos.Count() ) +/*N*/ InitWritingDirections( nPara ); +/*N*/ +/*N*/ BYTE nType = 0; +/*N*/ WritingDirectionInfos& rDirInfos = pParaPortion->aWritingDirectionInfos; +/*N*/ for ( USHORT n = 0; n < rDirInfos.Count(); n++ ) +/*N*/ { +/*N*/ if ( ( rDirInfos[n].nStartPos <= nPos ) && ( rDirInfos[n].nEndPos >= nPos ) ) +/*N*/ { +/*N*/ nRightToLeft = rDirInfos[n].nType; +/*N*/ if ( pStart ) +/*?*/ *pStart = rDirInfos[n].nStartPos; +/*N*/ if ( pEnd ) +/*?*/ *pEnd = rDirInfos[n].nEndPos; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ return nRightToLeft; +/*N*/ } + +/*N*/ SvxAdjust ImpEditEngine::GetJustification( USHORT nPara ) const +/*N*/ { +/*N*/ SvxAdjust eJustification = SVX_ADJUST_LEFT; +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ eJustification = ((const SvxAdjustItem&) GetParaAttrib( nPara, EE_PARA_JUST )).GetAdjust(); +/*N*/ +/*N*/ if ( IsRightToLeft( nPara ) ) +/*N*/ { +/*?*/ if ( eJustification == SVX_ADJUST_LEFT ) +/*?*/ eJustification = SVX_ADJUST_RIGHT; +/*?*/ else if ( eJustification == SVX_ADJUST_RIGHT ) +/*?*/ eJustification = SVX_ADJUST_LEFT; +/*N*/ } +/*N*/ } +/*N*/ return eJustification; +/*N*/ } + + +// ---------------------------------------------------------------------- +// Textaenderung +// ---------------------------------------------------------------------- + +/*N*/ void ImpEditEngine::ImpRemoveChars( const EditPaM& rPaM, USHORT nChars, EditUndoRemoveChars* pCurUndo ) +/*N*/ { +/*N*/ aEditDoc.RemoveChars( rPaM, nChars ); +/*N*/ TextModified(); +/*N*/ } + + + +/*N*/ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, BOOL bBackward ) +/*N*/ { +/*N*/ DBG_ASSERT( pLeft != pRight, "Den gleichen Absatz zusammenfuegen ?" ); +/*N*/ DBG_ASSERT( aEditDoc.GetPos( pLeft ) != USHRT_MAX, "Einzufuegenden Node nicht gefunden(1)" ); +/*N*/ DBG_ASSERT( aEditDoc.GetPos( pRight ) != USHRT_MAX, "Einzufuegenden Node nicht gefunden(2)" ); +/*N*/ +/*N*/ USHORT nParagraphTobeDeleted = aEditDoc.GetPos( pRight ); +/*N*/ DeletedNodeInfo* pInf = new DeletedNodeInfo( (ULONG)pRight, nParagraphTobeDeleted ); +/*N*/ aDeletedNodes.Insert( pInf, aDeletedNodes.Count() ); +/*N*/ +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 InsertUndo( new EditUndoConnectParas( this, +/*N*/ } +/*N*/ #endif +/*N*/ +/*N*/ if ( bBackward ) +/*N*/ { +/*?*/ pLeft->SetStyleSheet( pRight->GetStyleSheet(), TRUE ); +/*?*/ pLeft->GetContentAttribs().GetItems().Set( pRight->GetContentAttribs().GetItems() ); +/*?*/ pLeft->GetCharAttribs().GetDefFont() = pRight->GetCharAttribs().GetDefFont(); +/*N*/ } +/*N*/ +/*N*/ ParaAttribsChanged( pLeft ); +/*N*/ +/*N*/ // Erstmal Portions suchen, da pRight nach ConnectParagraphs weg. +/*N*/ ParaPortion* pLeftPortion = FindParaPortion( pLeft ); +/*N*/ ParaPortion* pRightPortion = FindParaPortion( pRight ); +/*N*/ DBG_ASSERT( pLeftPortion, "Blinde Portion in ImpConnectParagraphs(1)" ); +/*N*/ DBG_ASSERT( pRightPortion, "Blinde Portion in ImpConnectParagraphs(2)" ); +/*N*/ DBG_ASSERT( nParagraphTobeDeleted == GetParaPortions().GetPos( pRightPortion ), "NodePos != PortionPos?" ); +/*N*/ +/*N*/ if ( IsCallParaInsertedOrDeleted() ) +/*N*/ GetEditEnginePtr()->ParagraphDeleted( nParagraphTobeDeleted ); +/*N*/ +/*N*/ EditPaM aPaM = aEditDoc.ConnectParagraphs( pLeft, pRight ); +/*N*/ GetParaPortions().Remove( nParagraphTobeDeleted ); +/*N*/ delete pRightPortion; +/*N*/ +/*N*/ pLeftPortion->MarkSelectionInvalid( aPaM.GetIndex(), pLeft->Len() ); +/*N*/ +/*N*/ // der rechte Node wird von EditDoc::ConnectParagraphs() geloescht. +/*N*/ +/*N*/ if ( GetTextRanger() ) +/*N*/ { +/*?*/ // Durch das zusammenfuegen wird der linke zwar neu formatiert, aber +/*?*/ // wenn sich dessen Hoehe nicht aendert bekommt die Formatierung die +/*?*/ // Aenderung der Gesaamthoehe des Textes zu spaet mit... +/*?*/ for ( USHORT n = nParagraphTobeDeleted; n < GetParaPortions().Count(); n++ ) +/*?*/ { +/*?*/ ParaPortion* pPP = GetParaPortions().GetObject( n ); +/*?*/ pPP->MarkSelectionInvalid( 0, pPP->GetNode()->Len() ); +/*?*/ pPP->GetLines().Reset(); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ TextModified(); +/*N*/ +/*N*/ return aPaM; +/*N*/ } + + +/*N*/ EditPaM ImpEditEngine::ImpDeleteSelection( EditSelection aSel ) +/*N*/ { +/*N*/ if ( !aSel.HasRange() ) +/*?*/ return aSel.Min(); +/*N*/ +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ EditPaM aStartPaM( aSel.Min() ); +/*N*/ EditPaM aEndPaM( aSel.Max() ); +/*N*/ +/*N*/ CursorMoved( aStartPaM.GetNode() ); // nur damit neu eingestellte Attribute verschwinden... +/*N*/ CursorMoved( aEndPaM.GetNode() ); // nur damit neu eingestellte Attribute verschwinden... +/*N*/ +/*N*/ DBG_ASSERT( aStartPaM.GetIndex() <= aStartPaM.GetNode()->Len(), "Index im Wald in ImpDeleteSelection" ); +/*N*/ DBG_ASSERT( aEndPaM.GetIndex() <= aEndPaM.GetNode()->Len(), "Index im Wald in ImpDeleteSelection" ); +/*N*/ +/*N*/ USHORT nStartNode = aEditDoc.GetPos( aStartPaM.GetNode() ); +/*N*/ USHORT nEndNode = aEditDoc.GetPos( aEndPaM.GetNode() ); +/*N*/ +/*N*/ DBG_ASSERT( nEndNode != USHRT_MAX, "Start > End ?!" ); +/*N*/ DBG_ASSERT( nStartNode <= nEndNode, "Start > End ?!" ); +/*N*/ +/*N*/ // Alle Nodes dazwischen entfernen.... +/*N*/ for ( ULONG z = nStartNode+1; z < nEndNode; z++ ) +/*N*/ { +/*?*/ // Immer nStartNode+1, wegen Remove()! +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ImpRemoveParagraph( nStartNode+1 ); +/*N*/ } +/*N*/ +/*N*/ if ( aStartPaM.GetNode() != aEndPaM.GetNode() ) +/*N*/ { +/*N*/ // Den Rest des StartNodes... +/*N*/ USHORT nChars; +/*N*/ nChars = aStartPaM.GetNode()->Len() - aStartPaM.GetIndex(); +/*N*/ ImpRemoveChars( aStartPaM, nChars ); +/*N*/ ParaPortion* pPortion = FindParaPortion( aStartPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in ImpDeleteSelection(3)" ); +/*N*/ pPortion->MarkSelectionInvalid( aStartPaM.GetIndex(), aStartPaM.GetNode()->Len() ); +/*N*/ +/*N*/ // Den Anfang des EndNodes.... +/*N*/ nChars = aEndPaM.GetIndex(); +/*N*/ aEndPaM.SetIndex( 0 ); +/*N*/ ImpRemoveChars( aEndPaM, nChars ); +/*N*/ pPortion = FindParaPortion( aEndPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in ImpDeleteSelection(4)" ); +/*N*/ pPortion->MarkSelectionInvalid( 0, aEndPaM.GetNode()->Len() ); +/*N*/ // Zusammenfuegen.... +/*N*/ aStartPaM = ImpConnectParagraphs( aStartPaM.GetNode(), aEndPaM.GetNode() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nChars; +/*N*/ nChars = aEndPaM.GetIndex() - aStartPaM.GetIndex(); +/*N*/ ImpRemoveChars( aStartPaM, nChars ); +/*N*/ ParaPortion* pPortion = FindParaPortion( aStartPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in ImpDeleteSelection(5)" ); +/*N*/ pPortion->MarkInvalid( aEndPaM.GetIndex(), aStartPaM.GetIndex() - aEndPaM.GetIndex() ); +/*N*/ } +/*N*/ +/*N*/ UpdateSelections(); +/*N*/ TextModified(); +/*N*/ return aStartPaM; +/*N*/ } + + +/*N*/ EditPaM ImpEditEngine::ImpInsertText( EditSelection aCurSel, const XubString& rStr ) +/*N*/ { +/*N*/ EditPaM aPaM; +/*N*/ if ( aCurSel.HasRange() ) +/*N*/ aPaM = ImpDeleteSelection( aCurSel ); +/*N*/ else +/*N*/ aPaM = aCurSel.Max(); +/*N*/ +/*N*/ EditPaM aCurPaM( aPaM ); // fuers Invalidieren +/*N*/ +/*N*/ XubString aText( rStr ); +/*N*/ aText.ConvertLineEnd( LINEEND_LF ); +/*N*/ SfxVoidItem aTabItem( EE_FEATURE_TAB ); +/*N*/ +/*N*/ // Konvertiert nach LineSep = \n +/*N*/ // Token mit LINE_SEP abfragen, +/*N*/ // da der MAC-Compiler aus \n etwas anderes macht! +/*N*/ +/*N*/ USHORT nStart = 0; +/*N*/ while ( nStart < aText.Len() ) +/*N*/ { +/*N*/ USHORT nEnd = aText.Search( LINE_SEP, nStart ); +/*N*/ if ( nEnd == STRING_NOTFOUND ) +/*N*/ nEnd = aText.Len(); // nicht dereferenzieren! +/*N*/ +/*N*/ // Start == End => Leerzeile +/*N*/ if ( nEnd > nStart ) +/*N*/ { +/*N*/ XubString aLine( aText, nStart, nEnd-nStart ); +/*N*/ xub_StrLen nChars = aPaM.GetNode()->Len() + aLine.Len(); +/*N*/ if ( nChars > MAXCHARSINPARA ) +/*N*/ { +/*?*/ USHORT nMaxNewChars = MAXCHARSINPARA-aPaM.GetNode()->Len(); +/*?*/ nEnd -= ( aLine.Len() - nMaxNewChars ); // Dann landen die Zeichen im naechsten Absatz. +/*?*/ aLine.Erase( nMaxNewChars ); // Del Rest... +/*N*/ } +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*N*/ InsertUndo( new EditUndoInsertChars( this, CreateEPaM( aPaM ), aLine ) ); +/*N*/ #endif +/*N*/ // Tabs ? +/*N*/ if ( aLine.Search( '\t' ) == STRING_NOTFOUND ) +/*N*/ aPaM = aEditDoc.InsertText( aPaM, aLine ); +/*N*/ else +/*N*/ { +/*N*/ USHORT nStart2 = 0; +/*N*/ while ( nStart2 < aLine.Len() ) +/*N*/ { +/*N*/ USHORT nEnd2 = aLine.Search( '\t', nStart2 ); +/*N*/ if ( nEnd2 == STRING_NOTFOUND ) +/*?*/ nEnd2 = aLine.Len(); // nicht dereferenzieren! +/*N*/ +/*N*/ if ( nEnd2 > nStart2 ) +/*?*/ aPaM = aEditDoc.InsertText( aPaM, XubString( aLine, nStart2, nEnd2-nStart2 ) ); +/*N*/ if ( nEnd2 < aLine.Len() ) +/*N*/ { +/*N*/ // aPaM = ImpInsertFeature( EditSelection( aPaM, aPaM ), ); +/*N*/ aPaM = aEditDoc.InsertFeature( aPaM, aTabItem ); +/*N*/ } +/*N*/ nStart2 = nEnd2+1; +/*N*/ } +/*N*/ } +/*N*/ ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in InsertText" ); +/*N*/ pPortion->MarkInvalid( aCurPaM.GetIndex(), aLine.Len() ); +/*N*/ } +/*N*/ if ( nEnd < aText.Len() ) +/*N*/ aPaM = ImpInsertParaBreak( aPaM ); +/*N*/ +/*N*/ nStart = nEnd+1; +/*N*/ } +/*N*/ +/*N*/ TextModified(); +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::ImpFastInsertText( EditPaM aPaM, const XubString& rStr ) +/*N*/ { +/*N*/ DBG_ASSERT( rStr.Search( 0x0A ) == STRING_NOTFOUND, "FastInsertText: Zeilentrenner nicht erlaubt!" ); +/*N*/ DBG_ASSERT( rStr.Search( 0x0D ) == STRING_NOTFOUND, "FastInsertText: Zeilentrenner nicht erlaubt!" ); +/*N*/ DBG_ASSERT( rStr.Search( '\t' ) == STRING_NOTFOUND, "FastInsertText: Features nicht erlaubt!" ); +/*N*/ +/*N*/ if ( ( aPaM.GetNode()->Len() + rStr.Len() ) < MAXCHARSINPARA ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*?*/ InsertUndo( new EditUndoInsertChars( this, CreateEPaM( aPaM ), rStr ) ); +/*N*/ #endif +/*N*/ +/*N*/ aPaM = aEditDoc.InsertText( aPaM, rStr ); +/*N*/ TextModified(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aPaM = ImpInsertText( aPaM, rStr ); +/*N*/ } +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::ImpInsertFeature( EditSelection aCurSel, const SfxPoolItem& rItem ) +/*N*/ { +/*N*/ EditPaM aPaM; +/*N*/ if ( aCurSel.HasRange() ) +/*?*/ aPaM = ImpDeleteSelection( aCurSel ); +/*N*/ else +/*N*/ aPaM = aCurSel.Max(); +/*N*/ +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*N*/ InsertUndo( new EditUndoInsertFeature( this, CreateEPaM( aPaM ), rItem ) ); +/*N*/ #endif +/*N*/ aPaM = aEditDoc.InsertFeature( aPaM, rItem ); +/*N*/ +/*N*/ ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in InsertFeature" ); +/*N*/ pPortion->MarkInvalid( aPaM.GetIndex()-1, 1 ); +/*N*/ +/*N*/ TextModified(); +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::ImpInsertParaBreak( const EditPaM& rPaM, BOOL bKeepEndingAttribs ) +/*N*/ { +/*N*/ EditPaM aPaM( aEditDoc.InsertParaBreak( rPaM, bKeepEndingAttribs ) ); +/*N*/ +/*N*/ ParaPortion* pPortion = FindParaPortion( rPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in ImpInsertParaBreak" ); +/*N*/ pPortion->MarkInvalid( rPaM.GetIndex(), 0 ); +/*N*/ +/*N*/ // Optimieren: Nicht unnoetig viele GetPos auf die Listen ansetzen! +/*N*/ // Hier z.B. bei Undo, aber auch in allen anderen Methoden. +/*N*/ USHORT nPos = GetParaPortions().GetPos( pPortion ); +/*N*/ ParaPortion* pNewPortion = new ParaPortion( aPaM.GetNode() ); +/*N*/ GetParaPortions().Insert( pNewPortion, nPos + 1 ); +/*N*/ ParaAttribsChanged( pNewPortion->GetNode() ); +/*N*/ if ( IsCallParaInsertedOrDeleted() ) +/*N*/ GetEditEnginePtr()->ParagraphInserted( nPos+1 ); +/*N*/ +/*N*/ CursorMoved( rPaM.GetNode() ); // falls leeres Attribut entstanden. +/*N*/ TextModified(); +/*N*/ return aPaM; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::ImpFastInsertParagraph( USHORT nPara ) +/*N*/ { +/*N*/ ContentNode* pNode = new ContentNode( aEditDoc.GetItemPool() ); +/*N*/ // Falls FlatMode, wird spaeter kein Font eingestellt: +/*N*/ pNode->GetCharAttribs().GetDefFont() = aEditDoc.GetDefFont(); +/*N*/ +/*N*/ aEditDoc.Insert( pNode, nPara ); +/*N*/ +/*N*/ ParaPortion* pNewPortion = new ParaPortion( pNode ); +/*N*/ GetParaPortions().Insert( pNewPortion, nPara ); +/*N*/ if ( IsCallParaInsertedOrDeleted() ) +/*N*/ GetEditEnginePtr()->ParagraphInserted( nPara ); +/*N*/ +/*N*/ return EditPaM( pNode, 0 ); +/*N*/ } + +/*N*/ BOOL ImpEditEngine::UpdateFields() +/*N*/ { +/*N*/ BOOL bChanges = FALSE; +/*N*/ USHORT nParas = GetEditDoc().Count(); +/*N*/ for ( USHORT nPara = 0; nPara < nParas; nPara++ ) +/*N*/ { +/*N*/ BOOL bChangesInPara = FALSE; +/*N*/ ContentNode* pNode = GetEditDoc().GetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "NULL-Pointer im Doc" ); +/*N*/ CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ USHORT nAttrs = rAttribs.Count(); +/*N*/ for ( USHORT nAttr = 0; nAttr < rAttribs.Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttribs[nAttr]; +/*N*/ if ( pAttr->Which() == EE_FEATURE_FIELD ) +/*N*/ { +/*N*/ EditCharAttribField* pField = (EditCharAttribField*)pAttr; +/*N*/ EditCharAttribField* pCurrent = new EditCharAttribField( *pField ); +/*N*/ pField->Reset(); +/*N*/ +/*N*/ if ( aStatus.MarkFields() ) +/*N*/ pField->GetFldColor() = new Color( GetColorConfig().GetColorValue( WRITERFIELDSHADINGS ).nColor ); +/*N*/ +/*N*/ XubString aFldValue = GetEditEnginePtr()->CalcFieldValue( +/*N*/ (const SvxFieldItem&)*pField->GetItem(), +/*N*/ nPara, pField->GetStart(), +/*N*/ pField->GetTxtColor(), pField->GetFldColor() ); +/*N*/ pField->GetFieldValue() = aFldValue; +/*N*/ if ( *pField != *pCurrent ) +/*N*/ { +/*N*/ bChanges = TRUE; +/*N*/ bChangesInPara = TRUE; +/*N*/ } +/*N*/ delete pCurrent; +/*N*/ } +/*N*/ } +/*N*/ if ( bChangesInPara ) +/*N*/ { +/*N*/ // ggf. etwas genauer invalidieren. +/*N*/ ParaPortion* pPortion = GetParaPortions().GetObject( nPara ); +/*N*/ DBG_ASSERT( pPortion, "NULL-Pointer im Doc" ); +/*N*/ pPortion->MarkSelectionInvalid( 0, pNode->Len() ); +/*N*/ } +/*N*/ } +/*N*/ return bChanges; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::InsertLineBreak( EditSelection aCurSel ) +/*N*/ { +/*N*/ EditPaM aPaM( ImpInsertFeature( aCurSel, SfxVoidItem( EE_FEATURE_LINEBR ) ) ); +/*N*/ return aPaM; +/*N*/ } + +// ---------------------------------------------------------------------- +// Hilfsfunktionen +// ---------------------------------------------------------------------- + +/*N*/ EditPaM ImpEditEngine::GetPaM( Point aDocPos, BOOL bSmart ) +/*N*/ { +/*N*/ DBG_ASSERT( GetUpdateMode(), "Darf bei Update=FALSE nicht erreicht werden: GetPaM" ); +/*N*/ +/*N*/ long nY = 0; +/*N*/ long nTmpHeight; +/*N*/ EditPaM aPaM; +/*N*/ USHORT nPortion; +/*N*/ for ( nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ ) +/*N*/ { +/*N*/ ParaPortion* pPortion = GetParaPortions().GetObject(nPortion); +/*N*/ nTmpHeight = pPortion->GetHeight(); // sollte auch bei !bVisible richtig sein! +/*N*/ nY += nTmpHeight; +/*N*/ if ( nY > aDocPos.Y() ) +/*N*/ { +/*N*/ nY -= nTmpHeight; +/*N*/ aDocPos.Y() -= nY; +/*N*/ // unsichtbare Portions ueberspringen: +/*N*/ while ( pPortion && !pPortion->IsVisible() ) +/*N*/ { +/*?*/ nPortion++; +/*?*/ pPortion = GetParaPortions().SaveGetObject( nPortion ); +/*N*/ } +/*N*/ DBG_ASSERT( pPortion, "Keinen sichtbaren Absatz gefunden: GetPaM" ); +/*N*/ aPaM = GetPaM( pPortion, aDocPos, bSmart ); +/*N*/ return aPaM; +/*N*/ +/*N*/ } +/*N*/ } +/*?*/ // Dann den letzten sichtbaren Suchen: +/*?*/ nPortion = GetParaPortions().Count()-1; +/*?*/ while ( nPortion && !GetParaPortions()[nPortion]->IsVisible() ) +/*?*/ nPortion--; +/*?*/ +/*?*/ DBG_ASSERT( GetParaPortions()[nPortion]->IsVisible(), "Keinen sichtbaren Absatz gefunden: GetPaM" ); +/*?*/ aPaM.SetNode( GetParaPortions()[nPortion]->GetNode() ); +/*?*/ aPaM.SetIndex( GetParaPortions()[nPortion]->GetNode()->Len() ); +/*?*/ return aPaM; +/*N*/ } + +/*N*/ sal_uInt32 ImpEditEngine::GetTextHeight() const +/*N*/ { +/*N*/ DBG_ASSERT( GetUpdateMode(), "Sollte bei Update=FALSE nicht verwendet werden: GetTextHeight" ); +/*N*/ DBG_ASSERT( IsFormatted() || IsFormatting(), "GetTextHeight: Nicht formatiert" ); +/*N*/ return nCurTextHeight; +/*N*/ } + +/*N*/ sal_uInt32 ImpEditEngine::CalcTextWidth( BOOL bIgnoreExtraSpace ) +/*N*/ { +/*N*/ // Wenn noch nicht formatiert und nicht gerade dabei. +/*N*/ // Wird in der Formatierung bei AutoPageSize gerufen. +/*N*/ if ( !IsFormatted() && !IsFormatting() ) +/*?*/ FormatDoc(); +/*N*/ +/*N*/ EditLine* pLine; +/*N*/ +/*N*/ long nMaxWidth = 0; +/*N*/ long nCurWidth = 0; +/*N*/ +/*N*/ // -------------------------------------------------- +/*N*/ // Ueber alle Absaetze... +/*N*/ // -------------------------------------------------- +/*N*/ USHORT nParas = GetParaPortions().Count(); +/*N*/ USHORT nBiggestPara = 0; +/*N*/ USHORT nBiggestLine = 0; +/*N*/ for ( USHORT nPara = 0; nPara < nParas; nPara++ ) +/*N*/ { +/*N*/ ParaPortion* pPortion = GetParaPortions().GetObject( nPara ); +/*N*/ const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pPortion->GetNode() ); +/*N*/ +/*N*/ if ( pPortion->IsVisible() ) +/*N*/ { +/*N*/ // -------------------------------------------------- +/*N*/ // Ueber die Zeilen des Absatzes... +/*N*/ // -------------------------------------------------- +/*N*/ ULONG nLines = pPortion->GetLines().Count(); +/*N*/ for ( USHORT nLine = 0; nLine < nLines; nLine++ ) +/*N*/ { +/*N*/ pLine = pPortion->GetLines().GetObject( nLine ); +/*N*/ DBG_ASSERT( pLine, "NULL-Pointer im Zeileniterator in CalcWidth" ); +/*N*/ // nCurWidth = pLine->GetStartPosX(); +/*N*/ // Bei Center oder Right haengt die breite von der +/*N*/ // Papierbreite ab, hier nicht erwuenscht. +/*N*/ // Am besten generell nicht auf StartPosX verlassen, +/*N*/ // es muss auch die rechte Einrueckung beruecksichtigt werden! +/*N*/ nCurWidth = GetXValue( rLRItem.GetTxtLeft() ); +/*N*/ if ( nLine == 0 ) +/*N*/ { +/*N*/ long nFI = GetXValue( rLRItem.GetTxtFirstLineOfst() ); +/*N*/ nCurWidth += nFI; +/*N*/ if ( pPortion->GetBulletX() > nCurWidth ) +/*N*/ { +/*?*/ nCurWidth -= nFI; // LI? +/*?*/ if ( pPortion->GetBulletX() > nCurWidth ) +/*?*/ nCurWidth = pPortion->GetBulletX(); +/*N*/ } +/*N*/ } +/*N*/ nCurWidth += GetXValue( rLRItem.GetRight() ); +/*N*/ nCurWidth += CalcLineWidth( pPortion, pLine, bIgnoreExtraSpace ); +/*N*/ if ( nCurWidth > nMaxWidth ) +/*N*/ { +/*N*/ nMaxWidth = nCurWidth; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if ( nMaxWidth < 0 ) +/*?*/ nMaxWidth = 0; +/*N*/ +/*N*/ nMaxWidth++; // Ein breiter, da in CreateLines bei >= umgebrochen wird. +/*N*/ return (sal_uInt32)nMaxWidth; +/*N*/ } + +/*N*/ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, BOOL bIgnoreExtraSpace ) +/*N*/ { +/*N*/ USHORT nPara = GetEditDoc().GetPos( pPortion->GetNode() ); +/*N*/ ULONG nOldLayoutMode = GetRefDevice()->GetLayoutMode(); +/*N*/ +/*N*/ ImplInitLayoutMode( GetRefDevice(), nPara, 0xFFFF ); +/*N*/ +/*N*/ SvxAdjust eJustification = GetJustification( nPara ); +/*N*/ +/*N*/ // Berechnung der Breite ohne die Indents... +/*N*/ sal_uInt32 nWidth = 0; +/*N*/ USHORT nPos = pLine->GetStart(); +/*N*/ for ( USHORT nTP = pLine->GetStartPortion(); nTP <= pLine->GetEndPortion(); nTP++ ) +/*N*/ { +/*N*/ TextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( nTP ); +/*N*/ switch ( pTextPortion->GetKind() ) +/*N*/ { +/*N*/ case PORTIONKIND_FIELD: +/*N*/ case PORTIONKIND_HYPHENATOR: +/*N*/ case PORTIONKIND_TAB: +/*N*/ { +/*N*/ nWidth += pTextPortion->GetSize().Width(); +/*N*/ } +/*N*/ break; +/*N*/ case PORTIONKIND_TEXT: +/*N*/ { +/*N*/ if ( ( eJustification != SVX_ADJUST_BLOCK ) || ( !bIgnoreExtraSpace ) ) +/*N*/ { +/*N*/ nWidth += pTextPortion->GetSize().Width(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() ); +/*?*/ SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont ); +/*?*/ aTmpFont.SetPhysFont( GetRefDevice() ); +/*?*/ nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(), *pPortion->GetNode(), nPos, pTextPortion->GetLen(), NULL ).Width(); +/*N*/ } +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ nPos += pTextPortion->GetLen(); +/*N*/ } +/*N*/ +/*N*/ GetRefDevice()->SetLayoutMode( nOldLayoutMode ); +/*N*/ +/*N*/ return nWidth; +/*N*/ } + +/*N*/ sal_uInt32 ImpEditEngine::CalcTextHeight() +/*N*/ { +/*N*/ DBG_ASSERT( GetUpdateMode(), "Sollte bei Update=FALSE nicht verwendet werden: CalcTextHeight" ); +/*N*/ sal_uInt32 nY = 0; +/*N*/ for ( USHORT nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ ) +/*N*/ nY += GetParaPortions()[nPortion]->GetHeight(); +/*N*/ return nY; +/*N*/ } + +/*N*/ USHORT ImpEditEngine::GetLineCount( USHORT nParagraph ) const +/*N*/ { +/*N*/ DBG_ASSERT( nParagraph < GetParaPortions().Count(), "GetLineCount: Out of range" ); +/*N*/ ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nParagraph ); +/*N*/ DBG_ASSERT( pPPortion, "Absatz nicht gefunden: GetLineCount" ); +/*N*/ if ( pPPortion ) +/*N*/ return pPPortion->GetLines().Count(); +/*N*/ +/*N*/ return 0xFFFF; +/*N*/ } + + + + +/*N*/ void ImpEditEngine::UpdateSelections() +/*N*/ { +/*N*/ USHORT nInvNodes = aDeletedNodes.Count(); +/*N*/ +/*N*/ // Pruefen, ob eine der Selektionen auf einem geloeschten Node steht... +/*N*/ // Wenn der Node gueltig ist, muss noch der Index geprueft werden! +/*N*/ for ( USHORT nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*N*/ EditView* pView = aEditViews.GetObject(nView); +/*N*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ EditSelection aCurSel( pView->pImpEditView->GetEditSelection() ); +/*N*/ BOOL bChanged = FALSE; +/*N*/ for ( USHORT n = 0; n < nInvNodes; n++ ) +/*N*/ { +/*?*/ DeletedNodeInfo* pInf = aDeletedNodes.GetObject( n ); +/*?*/ if ( ( ( ULONG )(aCurSel.Min().GetNode()) == pInf->GetInvalidAdress() ) || +/*?*/ ( ( ULONG )(aCurSel.Max().GetNode()) == pInf->GetInvalidAdress() ) ) +/*?*/ { +/*?*/ // ParaPortions verwenden, da jetzt auch versteckte +/*?*/ // Absaetze beruecksichtigt werden muessen! +/*?*/ USHORT nPara = pInf->GetPosition(); +/*?*/ ParaPortion* pPPortion = GetParaPortions().SaveGetObject( nPara ); +/*?*/ if ( !pPPortion ) // letzter Absatz +/*?*/ { +/*?*/ nPara = GetParaPortions().Count()-1; +/*?*/ pPPortion = GetParaPortions().GetObject( nPara ); +/*?*/ } +/*?*/ DBG_ASSERT( pPPortion, "Leeres Document in UpdateSelections ?" ); +/*?*/ // Nicht aus einem verstecktem Absatz landen: +/*?*/ USHORT nCurPara = nPara; +/*?*/ USHORT nLastPara = GetParaPortions().Count()-1; +/*?*/ while ( nPara <= nLastPara && !GetParaPortions()[nPara]->IsVisible() ) +/*?*/ nPara++; +/*?*/ if ( nPara > nLastPara ) // dann eben rueckwaerts... +/*?*/ { +/*?*/ nPara = nCurPara; +/*?*/ while ( nPara && !GetParaPortions()[nPara]->IsVisible() ) +/*?*/ nPara--; +/*?*/ } +/*?*/ DBG_ASSERT( GetParaPortions()[nPara]->IsVisible(), "Keinen sichtbaren Absatz gefunden: UpdateSelections" ); +/*?*/ +/*?*/ ParaPortion* pParaPortion = GetParaPortions()[nPara]; +/*?*/ EditSelection aTmpSelection( EditPaM( pParaPortion->GetNode(), 0 ) ); +/*?*/ pView->pImpEditView->SetEditSelection( aTmpSelection ); +/*?*/ bChanged=TRUE; +/*?*/ break; // for-Schleife +/*?*/ } +/*N*/ } +/*N*/ if ( !bChanged ) +/*N*/ { +/*N*/ // Index prueffen, falls Node geschrumpft. +/*N*/ if ( aCurSel.Min().GetIndex() > aCurSel.Min().GetNode()->Len() ) +/*N*/ { +/*?*/ aCurSel.Min().GetIndex() = aCurSel.Min().GetNode()->Len(); +/*?*/ pView->pImpEditView->SetEditSelection( aCurSel ); +/*N*/ } +/*N*/ if ( aCurSel.Max().GetIndex() > aCurSel.Max().GetNode()->Len() ) +/*N*/ { +/*?*/ aCurSel.Max().GetIndex() = aCurSel.Max().GetNode()->Len(); +/*?*/ pView->pImpEditView->SetEditSelection( aCurSel ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Loeschen... +/*N*/ for ( USHORT n = 0; n < nInvNodes; n++ ) +/*N*/ { +/*N*/ DeletedNodeInfo* pInf = aDeletedNodes.GetObject( n ); +/*N*/ delete pInf; +/*N*/ } +/*N*/ aDeletedNodes.Remove( 0, aDeletedNodes.Count() ); +/*N*/ } + +/*N*/ EditSelection ImpEditEngine::ConvertSelection( USHORT nStartPara, USHORT nStartPos, +/*N*/ USHORT nEndPara, USHORT nEndPos ) const +/*N*/ { +/*N*/ EditSelection aNewSelection; +/*N*/ +/*N*/ // Start... +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nStartPara ); +/*N*/ USHORT nIndex = nStartPos; +/*N*/ if ( !pNode ) +/*N*/ { +/*?*/ pNode = aEditDoc[ aEditDoc.Count()-1 ]; +/*?*/ nIndex = pNode->Len(); +/*N*/ } +/*N*/ else if ( nIndex > pNode->Len() ) +/*?*/ nIndex = pNode->Len(); +/*N*/ +/*N*/ aNewSelection.Min().SetNode( pNode ); +/*N*/ aNewSelection.Min().SetIndex( nIndex ); +/*N*/ +/*N*/ // End... +/*N*/ pNode = aEditDoc.SaveGetObject( nEndPara ); +/*N*/ nIndex = nEndPos; +/*N*/ if ( !pNode ) +/*N*/ { +/*?*/ pNode = aEditDoc[ aEditDoc.Count()-1 ]; +/*?*/ nIndex = pNode->Len(); +/*N*/ } +/*N*/ else if ( nIndex > pNode->Len() ) +/*?*/ nIndex = pNode->Len(); +/*N*/ +/*N*/ aNewSelection.Max().SetNode( pNode ); +/*N*/ aNewSelection.Max().SetIndex( nIndex ); +/*N*/ +/*N*/ return aNewSelection; +/*N*/ } + + + +/*N*/ void ImpEditEngine::SetActiveView( EditView* pView ) +/*N*/ { +/*N*/ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ // Eigentlich waere jetzt ein bHasVisSel und HideSelection notwendig !!! +/*N*/ +/*N*/ if ( pView == pActiveView ) +/*N*/ return; +/*N*/ +/*N*/ if ( pActiveView && pActiveView->HasSelection() ) +/*?*/ pActiveView->pImpEditView->DrawSelection(); // Wegzeichnen... +/*N*/ +/*N*/ pActiveView = pView; +/*N*/ +/*N*/ if ( pActiveView && pActiveView->HasSelection() ) +/*?*/ pActiveView->pImpEditView->DrawSelection(); // Wegzeichnen... +/*N*/ +/*N*/ // NN: Quick fix for #78668#: +/*N*/ // When editing of a cell in Calc is ended, the edit engine is not deleted, +/*N*/ // only the edit views are removed. If mpIMEInfos is still set in that case, +/*N*/ // mpIMEInfos->aPos points to an invalid selection. +/*N*/ // -> reset mpIMEInfos now +/*N*/ // (probably something like this is necessary whenever the content is modified +/*N*/ // from the outside) +/*N*/ +/*N*/ if ( !pView && mpIMEInfos ) +/*N*/ { +/*?*/ delete mpIMEInfos; +/*?*/ mpIMEInfos = NULL; +/*N*/ } +/*N*/ } + + + +/*N*/ Range ImpEditEngine::GetInvalidYOffsets( ParaPortion* pPortion ) +/*N*/ { +/*N*/ Range aRange( 0, 0 ); +/*N*/ +/*N*/ if ( pPortion->IsVisible() ) +/*N*/ { +/*N*/ const SvxULSpaceItem& rULSpace = (const SvxULSpaceItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); +/*N*/ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ USHORT nSBL = ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) +/*N*/ ? GetYValue( rLSItem.GetInterLineSpace() ) : 0; +/*N*/ +/*N*/ // erst von vorne... +/*N*/ USHORT nFirstInvalid = 0xFFFF; +/*N*/ USHORT nLine; +/*N*/ for ( nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ ) +/*N*/ { +/*N*/ EditLine* pL = pPortion->GetLines().GetObject( nLine ); +/*N*/ if ( pL->IsInvalid() ) +/*N*/ { +/*N*/ nFirstInvalid = nLine; +/*N*/ break; +/*N*/ } +/*?*/ if ( nLine && !aStatus.IsOutliner() ) // nicht die erste Zeile +/*?*/ aRange.Min() += nSBL; +/*?*/ aRange.Min() += pL->GetHeight(); +/*N*/ } +/*N*/ DBG_ASSERT( nFirstInvalid != 0xFFFF, "Keine ungueltige Zeile gefunden in GetInvalidYOffset(1)" ); +/*N*/ +/*N*/ +/*N*/ // Abgleichen und weiter... +/*N*/ aRange.Max() = aRange.Min(); +/*N*/ aRange.Max() += pPortion->GetFirstLineOffset(); +/*N*/ if ( nFirstInvalid != 0 ) // Nur wenn nicht die erste Zeile ungueltig +/*?*/ aRange.Min() = aRange.Max(); +/*N*/ +/*N*/ USHORT nLastInvalid = pPortion->GetLines().Count()-1; +/*N*/ for ( nLine = nFirstInvalid; nLine < pPortion->GetLines().Count(); nLine++ ) +/*N*/ { +/*N*/ EditLine* pL = pPortion->GetLines().GetObject( nLine ); +/*N*/ if ( pL->IsValid() ) +/*N*/ { +/*?*/ nLastInvalid = nLine; +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ if ( nLine && !aStatus.IsOutliner() ) +/*N*/ aRange.Max() += nSBL; +/*N*/ aRange.Max() += pL->GetHeight(); +/*N*/ } +/*N*/ +/*N*/ // MT 07/00 SBL kann jetzt kleiner 100% sein => ggf. die Zeile davor neu ausgeben. +/*N*/ if( ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) && rLSItem.GetPropLineSpace() && +/*N*/ ( rLSItem.GetPropLineSpace() < 100 ) ) +/*N*/ { +/*?*/ EditLine* pL = pPortion->GetLines().GetObject( nFirstInvalid ); +/*?*/ long n = pL->GetTxtHeight() * ( 100 - rLSItem.GetPropLineSpace() ); +/*?*/ n /= 100; +/*?*/ aRange.Min() -= n; +/*?*/ aRange.Max() += n; +/*N*/ } +/*N*/ +/*N*/ if ( ( nLastInvalid == pPortion->GetLines().Count()-1 ) && ( !aStatus.IsOutliner() ) ) +/*N*/ aRange.Max() += GetYValue( rULSpace.GetLower() ); +/*N*/ } +/*N*/ return aRange; +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::GetPaM( ParaPortion* pPortion, Point aDocPos, BOOL bSmart ) +/*N*/ { +/*N*/ DBG_ASSERT( pPortion->IsVisible(), "Wozu GetPaM() bei einem unsichtbaren Absatz?" ); +/*N*/ DBG_ASSERT( IsFormatted(), "GetPaM: Nicht formatiert" ); +/*N*/ +/*N*/ USHORT nCurIndex = 0; +/*N*/ EditPaM aPaM; +/*N*/ aPaM.SetNode( pPortion->GetNode() ); +/*N*/ +/*N*/ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ USHORT nSBL = ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) +/*N*/ ? GetYValue( rLSItem.GetInterLineSpace() ) : 0; +/*N*/ +/*N*/ long nY = pPortion->GetFirstLineOffset(); +/*N*/ +/*N*/ DBG_ASSERT( pPortion->GetLines().Count(), "Leere ParaPortion in GetPaM!" ); +/*N*/ +/*N*/ EditLine* pLine = 0; +/*N*/ for ( USHORT nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ ) +/*N*/ { +/*N*/ EditLine* pTmpLine = pPortion->GetLines().GetObject( nLine ); +/*N*/ nY += pTmpLine->GetHeight(); +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ nY += nSBL; +/*N*/ if ( nY > aDocPos.Y() ) // das war 'se +/*N*/ { +/*N*/ pLine = pTmpLine; +/*N*/ break; // richtige Y-Position intressiert nicht +/*N*/ } +/*N*/ +/*?*/ nCurIndex += pTmpLine->GetLen(); +/*N*/ } +/*N*/ +/*N*/ if ( !pLine ) // darf nur im Bereich von SA passieren! +/*N*/ { +/*?*/ #ifdef DBG_UTIL +/*?*/ const SvxULSpaceItem& rULSpace =(const SvxULSpaceItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); +/*?*/ DBG_ASSERT( nY+GetYValue( rULSpace.GetLower() ) >= aDocPos.Y() , "Index in keiner Zeile, GetPaM ?" ); +/*?*/ #endif +/*?*/ aPaM.SetIndex( pPortion->GetNode()->Len() ); +/*?*/ return aPaM; +/*N*/ } +/*N*/ +/*N*/ // Wenn Zeile gefunden, nur noch X-Position => Index +/*N*/ nCurIndex = GetChar( pPortion, pLine, aDocPos.X(), bSmart ); +/*N*/ aPaM.SetIndex( nCurIndex ); +/*N*/ +/*N*/ if ( nCurIndex && ( nCurIndex == pLine->GetEnd() ) && +/*N*/ ( pLine != pPortion->GetLines().GetObject( pPortion->GetLines().Count()-1) ) ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 aPaM = CursorLeft( aPaM, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL ); +/*N*/ } +/*N*/ +/*N*/ return aPaM; +/*N*/ } + +/*N*/ USHORT ImpEditEngine::GetChar( ParaPortion* pParaPortion, EditLine* pLine, long nXPos, BOOL bSmart ) +/*N*/ { +/*N*/ DBG_ASSERT( pLine, "Keine Zeile erhalten: GetChar" ); +/*N*/ +/*N*/ USHORT nChar = 0xFFFF; +/*N*/ USHORT nCurIndex = pLine->GetStart(); +/*N*/ +/*N*/ +/*N*/ // Search best matching portion with GetPortionXOffset() +/*N*/ for ( USHORT i = pLine->GetStartPortion(); i <= pLine->GetEndPortion(); i++ ) +/*N*/ { +/*N*/ TextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( i ); +/*N*/ long nXLeft = GetPortionXOffset( pParaPortion, pLine, i ); +/*N*/ long nXRight = nXLeft + pPortion->GetSize().Width(); +/*N*/ if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) ) +/*N*/ { +/*N*/ nChar = nCurIndex; +/*N*/ +/*N*/ // Search within Portion... +/*N*/ +/*N*/ // Don't search within special portions... +/*N*/ if ( pPortion->GetKind() != PORTIONKIND_TEXT ) +/*N*/ { +/*?*/ // ...but check on which side +/*?*/ if ( bSmart ) +/*?*/ { +/*?*/ long nLeftDiff = nXPos-nXLeft; +/*?*/ long nRightDiff = nXRight-nXPos; +/*?*/ if ( nRightDiff < nLeftDiff ) +/*?*/ nChar++; +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ USHORT nMax = pPortion->GetLen(); +/*N*/ USHORT nOffset = 0xFFFF; +/*N*/ USHORT nTmpCurIndex = nChar - pLine->GetStart(); +/*N*/ +/*N*/ long nXInPortion = nXPos - nXLeft; +/*N*/ if ( pPortion->IsRightToLeft() ) +/*?*/ nXInPortion = nXRight - nXPos; +/*N*/ +/*N*/ // Search in Array... +/*N*/ for ( USHORT x = 0; x < nMax; x++ ) +/*N*/ { +/*N*/ long nTmpPosMax = pLine->GetCharPosArray().GetObject( nTmpCurIndex+x ); +/*N*/ if ( nTmpPosMax > nXInPortion ) +/*N*/ { +/*N*/ // pruefen, ob dieser oder der davor... +/*N*/ long nTmpPosMin = x ? pLine->GetCharPosArray().GetObject( nTmpCurIndex+x-1 ) : 0; +/*N*/ long nDiffLeft = nXInPortion - nTmpPosMin; +/*N*/ long nDiffRight = nTmpPosMax - nXInPortion; +/*N*/ DBG_ASSERT( nDiffLeft >= 0, "DiffLeft negativ" ); +/*N*/ DBG_ASSERT( nDiffRight >= 0, "DiffRight negativ" ); +/*N*/ nOffset = ( bSmart && ( nDiffRight < nDiffLeft ) ) ? x+1 : x; +/*N*/ // I18N: If there are character position with the length of 0, +/*N*/ // they belong to the same character, we can not use this position as an index. +/*N*/ // Skip all 0-positions, cheaper than using XBreakIterator: +/*N*/ if ( nOffset < nMax ) +/*N*/ { +/*N*/ const long nX = pLine->GetCharPosArray().GetObject(nOffset); +/*N*/ while ( ( (nOffset+1) < nMax ) && ( pLine->GetCharPosArray().GetObject(nOffset+1) == nX ) ) +/*N*/ nOffset++; +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Bei Verwendung des CharPosArray duerfte es keine Ungenauigkeiten geben! +/*N*/ // Vielleicht bei Kerning ? +/*N*/ // 0xFFF passiert z.B. bei Outline-Font, wenn ganz hinten. +/*N*/ if ( nOffset == 0xFFFF ) +/*N*/ nOffset = nMax; +/*N*/ +/*N*/ DBG_ASSERT( nOffset <= nMax, "nOffset > nMax" ); +/*N*/ +/*N*/ nChar += nOffset; +/*N*/ +/*N*/ // Check if index is within a cell: +/*N*/ if ( nChar && ( nChar < pParaPortion->GetNode()->Len() ) ) +/*N*/ { +/*N*/ EditPaM aPaM( pParaPortion->GetNode(), nChar+1 ); +/*N*/ USHORT nScriptType = GetScriptType( aPaM ); +/*N*/ if ( nScriptType == i18n::ScriptType::COMPLEX ) +/*N*/ { +/*?*/ uno::Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); +/*?*/ sal_Int32 nCount = 1; +/*?*/ lang::Locale aLocale = GetLocale( aPaM ); +/*?*/ USHORT nRight = (USHORT)xBI->nextCharacters( *pParaPortion->GetNode(), nChar, aLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount ); +/*?*/ USHORT nLeft = (USHORT)xBI->previousCharacters( *pParaPortion->GetNode(), nRight, aLocale, ::com::sun::star::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount ); +/*?*/ if ( ( nLeft != nChar ) && ( nRight != nChar ) ) +/*?*/ { +/*?*/ nChar = ( Abs( nRight - nChar ) < Abs( nLeft - nChar ) ) ? nRight : nLeft; +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ nCurIndex += pPortion->GetLen(); +/*N*/ } +/*N*/ +/*N*/ if ( nChar == 0xFFFF ) +/*N*/ { +/*?*/ nChar = ( nXPos <= pLine->GetStartPosX() ) ? pLine->GetStart() : pLine->GetEnd(); +/*N*/ } +/*N*/ +/*N*/ return nChar; +/*N*/ } + +/*N*/ Range ImpEditEngine::GetLineXPosStartEnd( ParaPortion* pParaPortion, EditLine* pLine ) +/*N*/ { +/*N*/ Range aLineXPosStartEnd; +/*N*/ +/*N*/ USHORT nPara = GetEditDoc().GetPos( pParaPortion->GetNode() ); +/*N*/ if ( !IsRightToLeft( nPara ) ) +/*N*/ { +/*N*/ aLineXPosStartEnd.Min() = pLine->GetStartPosX(); +/*N*/ aLineXPosStartEnd.Max() = pLine->GetStartPosX() + pLine->GetTextWidth(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aLineXPosStartEnd.Min() = GetPaperSize().Width() - ( pLine->GetStartPosX() + pLine->GetTextWidth() ); +/*?*/ aLineXPosStartEnd.Max() = GetPaperSize().Width() - pLine->GetStartPosX(); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ return aLineXPosStartEnd; +/*N*/ } + +/*N*/ long ImpEditEngine::GetPortionXOffset( ParaPortion* pParaPortion, EditLine* pLine, USHORT nTextPortion ) +/*N*/ { +/*N*/ long nX = pLine->GetStartPosX(); +/*N*/ +/*N*/ for ( USHORT i = pLine->GetStartPortion(); i < nTextPortion; i++ ) +/*N*/ { +/*N*/ TextPortion* pPortion = pParaPortion->GetTextPortions().GetObject( i ); +/*N*/ switch ( pPortion->GetKind() ) +/*N*/ { +/*N*/ case PORTIONKIND_FIELD: +/*N*/ case PORTIONKIND_TEXT: +/*N*/ case PORTIONKIND_HYPHENATOR: +/*N*/ case PORTIONKIND_TAB: +/*N*/ // case PORTIONKIND_EXTRASPACE: +/*N*/ { +/*N*/ nX += pPortion->GetSize().Width(); +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ USHORT nPara = GetEditDoc().GetPos( pParaPortion->GetNode() ); +/*N*/ BOOL bR2LPara = IsRightToLeft( nPara ); +/*N*/ +/*N*/ TextPortion* pDestPortion = pParaPortion->GetTextPortions().GetObject( nTextPortion ); +/*N*/ if ( pDestPortion->GetKind() != PORTIONKIND_TAB ) +/*N*/ { +/*N*/ if ( !bR2LPara && pDestPortion->GetRightToLeft() ) +/*N*/ { +/*?*/ // Portions behind must be added, visual before this portion +/*?*/ sal_uInt16 nTmpPortion = nTextPortion+1; +/*?*/ while ( nTmpPortion <= pLine->GetEndPortion() ) +/*?*/ { +/*?*/ TextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*?*/ if ( pNextTextPortion->GetRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) ) +/*?*/ nX += pNextTextPortion->GetSize().Width(); +/*?*/ else +/*?*/ break; +/*?*/ nTmpPortion++; +/*?*/ } +/*?*/ // Portions before must be removed, visual behind this portion +/*?*/ nTmpPortion = nTextPortion; +/*?*/ while ( nTmpPortion > pLine->GetStartPortion() ) +/*?*/ { +/*?*/ --nTmpPortion; +/*?*/ TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*?*/ if ( pPrevTextPortion->GetRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) ) +/*?*/ nX -= pPrevTextPortion->GetSize().Width(); +/*?*/ else +/*?*/ break; +/*?*/ } +/*N*/ } +/*N*/ else if ( bR2LPara && !pDestPortion->IsRightToLeft() ) +/*N*/ { +/*?*/ // Portions behind must be ermoved, visual behind this portion +/*?*/ sal_uInt16 nTmpPortion = nTextPortion+1; +/*?*/ while ( nTmpPortion <= pLine->GetEndPortion() ) +/*?*/ { +/*?*/ TextPortion* pNextTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*?*/ if ( !pNextTextPortion->IsRightToLeft() && ( pNextTextPortion->GetKind() != PORTIONKIND_TAB ) ) +/*?*/ nX += pNextTextPortion->GetSize().Width(); +/*?*/ else +/*?*/ break; +/*?*/ nTmpPortion++; +/*?*/ } +/*?*/ // Portions before must be added, visual before this portion +/*?*/ nTmpPortion = nTextPortion; +/*?*/ while ( nTmpPortion > pLine->GetStartPortion() ) +/*?*/ { +/*?*/ --nTmpPortion; +/*?*/ TextPortion* pPrevTextPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*?*/ if ( !pPrevTextPortion->IsRightToLeft() && ( pPrevTextPortion->GetKind() != PORTIONKIND_TAB ) ) +/*?*/ nX -= pPrevTextPortion->GetSize().Width(); +/*?*/ else +/*?*/ break; +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ if ( bR2LPara ) +/*N*/ { +/*?*/ // Switch X postions... +/*?*/ DBG_ASSERT( GetTextRanger() || GetPaperSize().Width(), "GetPortionXOffset - paper size?!" ); +/*?*/ DBG_ASSERT( GetTextRanger() || (nX <= GetPaperSize().Width()), "GetPortionXOffset - position out of paper size!" ); +/*?*/ nX = GetPaperSize().Width() - nX; +/*?*/ nX -= pDestPortion->GetSize().Width(); +/*N*/ } +/*N*/ +/*N*/ return nX; +/*N*/ } + + +/*N*/ void ImpEditEngine::CalcHeight( ParaPortion* pPortion ) +/*N*/ { +/*N*/ pPortion->nHeight = 0; +/*N*/ pPortion->nFirstLineOffset = 0; +/*N*/ +/*N*/ if ( pPortion->IsVisible() ) +/*N*/ { +/*N*/ DBG_ASSERT( pPortion->GetLines().Count(), "Absatz ohne Zeilen in ParaPortion::CalcHeight" ); +/*N*/ for ( USHORT nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ ) +/*N*/ pPortion->nHeight += pPortion->GetLines().GetObject( nLine )->GetHeight(); +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); +/*N*/ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ USHORT nSBL = ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) ? GetYValue( rLSItem.GetInterLineSpace() ) : 0; +/*N*/ +/*N*/ if ( nSBL ) +/*N*/ { +/*?*/ if ( pPortion->GetLines().Count() > 1 ) +/*?*/ pPortion->nHeight += ( pPortion->GetLines().Count() - 1 ) * nSBL; +/*?*/ if ( aStatus.ULSpaceSummation() ) +/*?*/ pPortion->nHeight += nSBL; +/*N*/ } +/*N*/ +/*N*/ USHORT nPortion = GetParaPortions().GetPos( pPortion ); +/*N*/ if ( nPortion || aStatus.ULSpaceFirstParagraph() ) +/*N*/ { +/*N*/ USHORT nUpper = GetYValue( rULItem.GetUpper() ); +/*N*/ pPortion->nHeight += nUpper; +/*N*/ pPortion->nFirstLineOffset = nUpper; +/*N*/ } +/*N*/ +/*N*/ if ( ( nPortion != (GetParaPortions().Count()-1) ) ) +/*N*/ { +/*N*/ pPortion->nHeight += GetYValue( rULItem.GetLower() ); // nicht in letzter +/*N*/ } +/*N*/ +/*N*/ +/*N*/ if ( nPortion && !aStatus.ULSpaceSummation() ) +/*N*/ { +/*N*/ ParaPortion* pPrev = GetParaPortions().SaveGetObject( nPortion-1 ); +/*N*/ const SvxULSpaceItem& rPrevULItem = (const SvxULSpaceItem&)pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); +/*N*/ const SvxLineSpacingItem& rPrevLSItem = (const SvxLineSpacingItem&)pPrev->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ +/*N*/ // Verhalten WinWord6/Writer3: +/*N*/ // Bei einem proportionalen Zeilenabstand wird auch der Absatzabstand +/*N*/ // manipuliert. +/*N*/ // Nur Writer3: Nicht aufaddieren, sondern Mindestabstand. +/*N*/ +/*N*/ // Pruefen, ob Abstand durch LineSpacing > Upper: +/*N*/ USHORT nExtraSpace = GetYValue( lcl_CalcExtraSpace( pPortion, rLSItem ) ); +/*N*/ if ( nExtraSpace > pPortion->nFirstLineOffset ) +/*N*/ { +/*?*/ // Absatz wird 'groesser': +/*?*/ pPortion->nHeight += ( nExtraSpace - pPortion->nFirstLineOffset ); +/*?*/ pPortion->nFirstLineOffset = nExtraSpace; +/*N*/ } +/*N*/ +/*N*/ // nFirstLineOffset jetzt f(pNode) => jetzt f(pNode, pPrev) ermitteln: +/*N*/ USHORT nPrevLower = GetYValue( rPrevULItem.GetLower() ); +/*N*/ +/*N*/ // Dieser PrevLower steckt noch in der Hoehe der PrevPortion... +/*N*/ if ( nPrevLower > pPortion->nFirstLineOffset ) +/*N*/ { +/*N*/ // Absatz wird 'kleiner': +/*N*/ pPortion->nHeight -= pPortion->nFirstLineOffset; +/*N*/ pPortion->nFirstLineOffset = 0; +/*N*/ } +/*N*/ else if ( nPrevLower ) +/*N*/ { +/*?*/ // Absatz wird 'etwas kleiner': +/*?*/ pPortion->nHeight -= nPrevLower; +/*?*/ pPortion->nFirstLineOffset -= nPrevLower; +/*N*/ } +/*N*/ +/*N*/ // Finde ich zwar nicht so gut, aber Writer3-Feature: +/*N*/ // Pruefen, ob Abstand durch LineSpacing > Lower: +/*N*/ // Dieser Wert steckt nicht in der Hoehe der PrevPortion. +/*N*/ if ( !pPrev->IsInvalid() ) +/*N*/ { +/*N*/ nExtraSpace = GetYValue( lcl_CalcExtraSpace( pPrev, rPrevLSItem ) ); +/*N*/ if ( nExtraSpace > nPrevLower ) +/*N*/ { +/*?*/ USHORT nMoreLower = nExtraSpace - nPrevLower; +/*?*/ // Absatz wird 'groesser', 'waechst' nach unten: +/*?*/ if ( nMoreLower > pPortion->nFirstLineOffset ) +/*?*/ { +/*?*/ pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset ); +/*?*/ pPortion->nFirstLineOffset = nMoreLower; +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ImpEditEngine::SetValidPaperSize( const Size& rNewSz ) +/*N*/ { +/*N*/ aPaperSize = rNewSz; +/*N*/ +/*N*/ long nMinWidth = aStatus.AutoPageWidth() ? aMinAutoPaperSize.Width() : 0; +/*N*/ long nMaxWidth = aStatus.AutoPageWidth() ? aMaxAutoPaperSize.Width() : 0x7FFFFFFF; +/*N*/ long nMinHeight = aStatus.AutoPageHeight() ? aMinAutoPaperSize.Height() : 0; +/*N*/ long nMaxHeight = aStatus.AutoPageHeight() ? aMaxAutoPaperSize.Height() : 0x7FFFFFFF; +/*N*/ +/*N*/ // Minimale/Maximale Breite: +/*N*/ if ( aPaperSize.Width() < nMinWidth ) +/*N*/ aPaperSize.Width() = nMinWidth; +/*N*/ else if ( aPaperSize.Width() > nMaxWidth ) +/*?*/ aPaperSize.Width() = nMaxWidth; +/*N*/ +/*N*/ // Minimale/Maximale Hoehe: +/*N*/ if ( aPaperSize.Height() < nMinHeight ) +/*?*/ aPaperSize.Height() = nMinHeight; +/*N*/ else if ( aPaperSize.Height() > nMaxHeight ) +/*?*/ aPaperSize.Height() = nMaxHeight; +/*N*/ } + + +/*N*/ rtl::Reference<SvxForbiddenCharactersTable> ImpEditEngine::GetForbiddenCharsTable( BOOL bGetInternal ) const +/*N*/ { +/*N*/ rtl::Reference<SvxForbiddenCharactersTable> xF = xForbiddenCharsTable; +/*N*/ if ( !xF.is() && bGetInternal ) +/*N*/ xF = EE_DLL()->GetGlobalData()->GetForbiddenCharsTable(); +/*N*/ return xF; +/*N*/ } + +/*N*/ void ImpEditEngine::SetForbiddenCharsTable( rtl::Reference<SvxForbiddenCharactersTable> xForbiddenChars ) +/*N*/ { +/*N*/ EE_DLL()->GetGlobalData()->SetForbiddenCharsTable( xForbiddenChars ); +/*N*/ } + + ColorConfig& ImpEditEngine::GetColorConfig() +/*N*/ { +/*N*/ if ( !pColorConfig ) +/*N*/ pColorConfig = new ColorConfig; +/*N*/ +/*N*/ return *pColorConfig; +/*N*/ } + + + + + +/*N*/ void ImpEditEngine::EnterBlockNotifications() +/*N*/ { +/*N*/ if( !nBlockNotifications ) +/*N*/ { +/*N*/ // #109864# Send out START notification immediately, to allow +/*N*/ // external, non-queued events to be captured as well from +/*N*/ // client side +/*N*/ EENotify aNotify( EE_NOTIFY_BLOCKNOTIFICATION_START ); +/*N*/ aNotify.pEditEngine = GetEditEnginePtr(); +/*N*/ GetNotifyHdl().Call( &aNotify ); +/*N*/ } +/*N*/ +/*N*/ nBlockNotifications++; +/*N*/ } + +/*N*/ void ImpEditEngine::LeaveBlockNotifications() +/*N*/ { +/*N*/ DBG_ASSERT( nBlockNotifications, "LeaveBlockNotifications - Why?" ); +/*N*/ +/*N*/ nBlockNotifications--; +/*N*/ if ( !nBlockNotifications ) +/*N*/ { +/*N*/ // Call blocked notify events... +/*N*/ while ( aNotifyCache.Count() ) +/*N*/ { +/*N*/ EENotify* pNotify = aNotifyCache[0]; +/*N*/ // Remove from list before calling, maybe we enter LeaveBlockNotifications while calling the handler... +/*N*/ aNotifyCache.Remove( 0 ); +/*N*/ GetNotifyHdl().Call( pNotify ); +/*N*/ delete pNotify; +/*N*/ } +/*N*/ +/*N*/ EENotify aNotify( EE_NOTIFY_BLOCKNOTIFICATION_END ); +/*N*/ aNotify.pEditEngine = GetEditEnginePtr(); +/*N*/ GetNotifyHdl().Call( &aNotify ); +/*N*/ } +/*N*/ } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_impedit3.cxx b/binfilter/bf_svx/source/editeng/svx_impedit3.cxx new file mode 100644 index 000000000000..ff5de653ba34 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_impedit3.cxx @@ -0,0 +1,3113 @@ +/* -*- 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. + * + ************************************************************************/ + + + +#define _SVSTDARR_USHORTS + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitemid.hxx" + +#include <adjitem.hxx> +#include <tstpitem.hxx> +#include <lspcitem.hxx> + + + +#include "itemdata.hxx" + +#include <tools/date.hxx> + +#include <tools/time.hxx> + +#include <flditem.hxx> + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> +#include <editview.hxx> +#include <txtrange.hxx> +#include <udlnitem.hxx> +#include <fhgtitem.hxx> +#include <kernitem.hxx> +#include <lrspitem.hxx> +#include <ulspitem.hxx> +#include <fontitem.hxx> +#include <wghtitem.hxx> +#include <postitem.hxx> +#include <langitem.hxx> +#include <scriptspaceitem.hxx> +#include <charscaleitem.hxx> + +#include <bf_svtools/colorcfg.hxx> + +#include <forbiddencharacterstable.hxx> + + +#include <unolingu.hxx> + +#include <math.h> + +#include <vcl/svapp.hxx> + + +#include <vcl/metric.hxx> + +#include <com/sun/star/i18n/ScriptType.hpp> + +#include <i18npool/mslangid.hxx> + + +#include <legacysmgr/legacy_binfilters_smgr.hxx> //STRIP002 +namespace binfilter { + +using ::rtl::OUString; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::linguistic2; + +/*N*/ SV_DECL_VARARR_SORT( SortedPositions, sal_uInt32, 16, 8 )//STRIP008 ; +/*N*/ SV_IMPL_VARARR_SORT( SortedPositions, sal_uInt32 ); + +#define CH_HYPH '-' + +#define RESDIFF 10 + +#define WRONG_SHOW_MIN 5 +#define WRONG_SHOW_SMALL 11 +#define WRONG_SHOW_MEDIUM 15 + +struct TabInfo +{ + BOOL bValid; + + SvxTabStop aTabStop; + xub_StrLen nCharPos; + USHORT nTabPortion; + long nStartPosX; + long nTabPos; + + TabInfo() { bValid = FALSE; } +}; + + + + + + + + +// ---------------------------------------------------------------------- +// class ImpEditEngine +// ---------------------------------------------------------------------- +/*N*/ void ImpEditEngine::UpdateViews( EditView* pCurView ) +/*N*/ { +/*N*/ if ( !GetUpdateMode() || IsFormatting() || aInvalidRec.IsEmpty() ) +/*N*/ return; +/*N*/ +/*N*/ DBG_ASSERT( IsFormatted(), "UpdateViews: Doc nicht formatiert!" ); +/*N*/ +/*N*/ for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*N*/ EditView* pView = aEditViews[nView]; +/*N*/ DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ pView->HideCursor(); +/*N*/ +/*N*/ Rectangle aClipRec( aInvalidRec ); +/*N*/ Rectangle aVisArea( pView->GetVisArea() ); +/*N*/ aClipRec.Intersection( aVisArea ); +/*N*/ +/*N*/ if ( !aClipRec.IsEmpty() ) +/*N*/ { +/*N*/ // in Fensterkoordinaten umwandeln.... +/*N*/ aClipRec = pView->pImpEditView->GetWindowPos( aClipRec ); +/*N*/ +/*N*/ if ( ( pView == pCurView ) ) +/*N*/ Paint( pView->pImpEditView, aClipRec, sal_True ); +/*N*/ else +/*N*/ pView->GetWindow()->Invalidate( aClipRec ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pCurView ) +/*N*/ { +/*N*/ sal_Bool bGotoCursor = pCurView->pImpEditView->DoAutoScroll(); +/*N*/ pCurView->ShowCursor( bGotoCursor ); +/*N*/ } +/*N*/ +/*N*/ aInvalidRec = Rectangle(); +/*N*/ } + +/*N*/ void ImpEditEngine::FormatFullDoc() +/*N*/ { +/*N*/ for ( sal_uInt16 nPortion = 0; nPortion < GetParaPortions().Count(); nPortion++ ) +/*N*/ GetParaPortions()[nPortion]->MarkSelectionInvalid( 0, GetParaPortions()[nPortion]->GetNode()->Len() ); +/*N*/ FormatDoc(); +/*N*/ } + +/*N*/ void ImpEditEngine::FormatDoc() +/*N*/ { +/*N*/ if ( !GetUpdateMode() || IsFormatting() ) +/*N*/ return; +/*N*/ +/*N*/ EnterBlockNotifications(); +/*N*/ +/*N*/ bIsFormatting = sal_True; +/*N*/ +/*N*/ long nY = 0; +/*N*/ sal_Bool bGrow = sal_False; +/*N*/ +/*N*/ Font aOldFont( GetRefDevice()->GetFont() ); +/*N*/ +/*N*/ // Hier schon, damit nicht jedesmal in CreateLines... +/*N*/ sal_Bool bMapChanged = ImpCheckRefMapMode(); +/*N*/ +/*N*/ aInvalidRec = Rectangle(); // leermachen +/*N*/ for ( sal_uInt16 nPara = 0; nPara < GetParaPortions().Count(); nPara++ ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().GetObject( nPara ); +/*N*/ if ( pParaPortion->MustRepaint() || ( pParaPortion->IsInvalid() && pParaPortion->IsVisible() ) ) +/*N*/ { +/*N*/ if ( pParaPortion->IsInvalid() ) +/*N*/ { +/*N*/ sal_Bool bChangedByDerivedClass = GetEditEnginePtr()->FormattingParagraph( nPara ); +/*N*/ if ( bChangedByDerivedClass ) +/*N*/ { +/*?*/ pParaPortion->GetTextPortions().Reset(); +/*?*/ pParaPortion->MarkSelectionInvalid( 0, pParaPortion->GetNode()->Len() ); +/*N*/ } +/*N*/ } +/*N*/ // bei MustRepaint() sollte keine Formatierung noetig sein! +/*N*/ // 23.1.95: Evtl. ist sie durch eine andere Aktion aber doch +/*N*/ // ungueltig geworden! +/*N*/ // if ( pParaPortion->MustRepaint() || CreateLines( nPara ) ) +/*N*/ if ( ( pParaPortion->MustRepaint() && !pParaPortion->IsInvalid() ) +/*N*/ || CreateLines( nPara, nY ) ) +/*N*/ { +/*N*/ if ( !bGrow && GetTextRanger() ) +/*N*/ { +/*?*/ // Bei einer Aenderung der Hoehe muss alles weiter unten +/*?*/ // neu formatiert werden... +/*?*/ for ( sal_uInt16 n = nPara+1; n < GetParaPortions().Count(); n++ ) +/*?*/ { +/*?*/ ParaPortion* pPP = GetParaPortions().GetObject( n ); +/*?*/ pPP->MarkSelectionInvalid( 0, pPP->GetNode()->Len() ); +/*?*/ pPP->GetLines().Reset(); +/*?*/ } +/*N*/ } +/*N*/ bGrow = sal_True; +/*N*/ if ( IsCallParaInsertedOrDeleted() ) +/*N*/ GetEditEnginePtr()->ParagraphHeightChanged( nPara ); +/*N*/ pParaPortion->SetMustRepaint( sal_False ); +/*N*/ } +/*N*/ +/*N*/ // InvalidRec nur einmal setzen... +/*N*/ if ( aInvalidRec.IsEmpty() ) +/*N*/ { +/*N*/ // Bei Paperwidth 0 (AutoPageSize) bleibt es sonst Empty()... +/*N*/ long nWidth = Max( (long)1, ( !IsVertical() ? aPaperSize.Width() : aPaperSize.Height() ) ); +/*N*/ Range aInvRange( GetInvalidYOffsets( pParaPortion ) ); +/*N*/ aInvalidRec = Rectangle( Point( 0, nY+aInvRange.Min() ), +/*N*/ Size( nWidth, aInvRange.Len() ) ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aInvalidRec.Bottom() = nY + pParaPortion->GetHeight(); +/*N*/ } +/*N*/ } +/*N*/ else if ( bGrow ) +/*N*/ { +/*?*/ aInvalidRec.Bottom() = nY + pParaPortion->GetHeight(); +/*N*/ } +/*N*/ nY += pParaPortion->GetHeight(); +/*N*/ } +/*N*/ +/*N*/ // Man kann auch durch UpdateMode An=>AUS=>AN in die Formatierung gelangen... +/*N*/ // Optimierung erst nach Vobis-Auslieferung aktivieren... +/*N*/ // if ( !aInvalidRec.IsEmpty() ) +/*N*/ { +/*N*/ sal_uInt32 nNewHeight = CalcTextHeight(); +/*N*/ long nDiff = nNewHeight - nCurTextHeight; +/*N*/ if ( nDiff ) +/*N*/ aStatus.GetStatusWord() |= !IsVertical() ? EE_STAT_TEXTHEIGHTCHANGED : EE_STAT_TEXTWIDTHCHANGED; +/*N*/ if ( nNewHeight < nCurTextHeight ) +/*N*/ { +/*N*/ aInvalidRec.Bottom() = (long)Max( nNewHeight, nCurTextHeight ); +/*N*/ if ( aInvalidRec.IsEmpty() ) +/*N*/ { +/*?*/ aInvalidRec.Top() = 0; +/*?*/ // Left und Right werden nicht ausgewertet, aber wegen IsEmpty gesetzt. +/*?*/ aInvalidRec.Left() = 0; +/*?*/ aInvalidRec.Right() = !IsVertical() ? aPaperSize.Width() : aPaperSize.Height(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ nCurTextHeight = nNewHeight; +/*N*/ +/*N*/ if ( aStatus.AutoPageSize() ) +/*N*/ CheckAutoPageSize(); +/*N*/ else if ( nDiff ) +/*N*/ { +/*N*/ for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*N*/ EditView* pView = aEditViews[nView]; +/*N*/ ImpEditView* pImpView = pView->pImpEditView; +/*N*/ if ( pImpView->DoAutoHeight() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 Size aSz( pImpView->GetOutputArea().GetWidth(), nCurTextHeight ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( aStatus.DoRestoreFont() ) +/*?*/ GetRefDevice()->SetFont( aOldFont ); +/*N*/ bIsFormatting = sal_False; +/*N*/ bFormatted = sal_True; +/*N*/ +/*N*/ if ( bMapChanged ) +/*N*/ GetRefDevice()->Pop(); +/*N*/ +/*N*/ LeaveBlockNotifications(); +/*N*/ } + +/*N*/ sal_Bool ImpEditEngine::ImpCheckRefMapMode() +/*N*/ { +/*N*/ sal_Bool bChange = sal_False; +/*N*/ +/*N*/ if ( aStatus.DoFormat100() ) +/*N*/ { +/*N*/ MapMode aMapMode( GetRefDevice()->GetMapMode() ); +/*N*/ if ( aMapMode.GetScaleX().GetNumerator() != aMapMode.GetScaleX().GetDenominator() ) +/*N*/ bChange = sal_True; +/*N*/ else if ( aMapMode.GetScaleY().GetNumerator() != aMapMode.GetScaleY().GetDenominator() ) +/*N*/ bChange = sal_True; +/*N*/ +/*N*/ if ( bChange ) +/*N*/ { +/*N*/ Fraction Scale1( 1, 1 ); +/*N*/ aMapMode.SetScaleX( Scale1 ); +/*N*/ aMapMode.SetScaleY( Scale1 ); +/*N*/ GetRefDevice()->Push(); +/*N*/ GetRefDevice()->SetMapMode( aMapMode ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return bChange; +/*N*/ } + +/*N*/ void ImpEditEngine::CheckAutoPageSize() +/*N*/ { +/*N*/ Size aPrevPaperSize( GetPaperSize() ); +/*N*/ if ( GetStatus().AutoPageWidth() ) +/*N*/ aPaperSize.Width() = (long) !IsVertical() ? CalcTextWidth( TRUE ) : GetTextHeight(); +/*N*/ if ( GetStatus().AutoPageHeight() ) +/*N*/ aPaperSize.Height() = (long) !IsVertical() ? GetTextHeight() : CalcTextWidth( TRUE ); +/*N*/ +/*N*/ SetValidPaperSize( aPaperSize ); //Min, Max beruecksichtigen +/*N*/ +/*N*/ if ( aPaperSize != aPrevPaperSize ) +/*N*/ { +/*N*/ if ( ( !IsVertical() && ( aPaperSize.Width() != aPrevPaperSize.Width() ) ) +/*N*/ || ( IsVertical() && ( aPaperSize.Height() != aPrevPaperSize.Height() ) ) ) +/*N*/ { +/*N*/ // Falls davor zentriert/rechts oder Tabs... +/*N*/ aStatus.GetStatusWord() |= !IsVertical() ? EE_STAT_TEXTWIDTHCHANGED : EE_STAT_TEXTHEIGHTCHANGED; +/*N*/ for ( sal_uInt16 nPara = 0; nPara < GetParaPortions().Count(); nPara++ ) +/*N*/ { +/*N*/ // Es brauchen nur Absaetze neu formatiert werden, +/*N*/ // die nicht linksbuendig sind. +/*N*/ // Die Hoehe kann sich hier nicht mehr aendern. +/*N*/ ParaPortion* pParaPortion = GetParaPortions().GetObject( nPara ); +/*N*/ ContentNode* pNode = pParaPortion->GetNode(); +/*N*/ SvxAdjust eJustification = GetJustification( nPara ); +/*N*/ if ( eJustification != SVX_ADJUST_LEFT ) +/*N*/ { +/*N*/ pParaPortion->MarkSelectionInvalid( 0, pNode->Len() ); +/*N*/ CreateLines( nPara, 0 ); // 0: Bei AutoPageSize kein TextRange! +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ Size aInvSize = aPaperSize; +/*N*/ if ( aPaperSize.Width() < aPrevPaperSize.Width() ) +/*?*/ aInvSize.Width() = aPrevPaperSize.Width(); +/*N*/ if ( aPaperSize.Height() < aPrevPaperSize.Height() ) +/*N*/ aInvSize.Height() = aPrevPaperSize.Height(); +/*N*/ +/*N*/ Size aSz( aInvSize ); +/*N*/ if ( IsVertical() ) +/*N*/ { +/*?*/ aSz.Width() = aInvSize.Height(); +/*?*/ aSz.Height() = aInvSize.Width(); +/*N*/ } +/*N*/ aInvalidRec = Rectangle( Point(), aSz ); +/*N*/ +/*N*/ +/*N*/ for ( sal_uInt16 nView = 0; nView < aEditViews.Count(); nView++ ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditView* pView = aEditViews[nView]; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ sal_Bool ImpEditEngine::CreateLines( USHORT nPara, sal_uInt32 nStartPosY ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions().GetObject( nPara ); +/*N*/ +/*N*/ // sal_Bool: Aenderung der Hoehe des Absatzes Ja/Nein - sal_True/sal_False +/*N*/ DBG_ASSERT( pParaPortion->GetNode(), "Portion ohne Node in CreateLines" ); +/*N*/ DBG_ASSERT( pParaPortion->IsVisible(), "Unsichtbare Absaetze nicht formatieren!" ); +/*N*/ DBG_ASSERT( pParaPortion->IsInvalid(), "CreateLines: Portion nicht invalid!" ); +/*N*/ +/*N*/ BOOL bProcessingEmptyLine = ( pParaPortion->GetNode()->Len() == 0 ); +/*N*/ BOOL bEmptyNodeWithPolygon = ( pParaPortion->GetNode()->Len() == 0 ) && GetTextRanger(); +/*N*/ +/*N*/ // --------------------------------------------------------------- +/*N*/ // Schnelle Sonderbehandlung fuer leere Absaetze... +/*N*/ // --------------------------------------------------------------- +/*N*/ if ( ( pParaPortion->GetNode()->Len() == 0 ) && !GetTextRanger() ) +/*N*/ { +/*N*/ // schnelle Sonderbehandlung... +/*N*/ if ( pParaPortion->GetTextPortions().Count() ) +/*N*/ pParaPortion->GetTextPortions().Reset(); +/*N*/ if ( pParaPortion->GetLines().Count() ) +/*N*/ pParaPortion->GetLines().Reset(); +/*N*/ CreateAndInsertEmptyLine( pParaPortion, nStartPosY ); +/*N*/ return FinishCreateLines( pParaPortion ); +/*N*/ } +/*N*/ +/*N*/ // --------------------------------------------------------------- +/*N*/ // Initialisierung...... +/*N*/ // --------------------------------------------------------------- +/*N*/ +/*N*/ // Immer fuer 100% formatieren: +/*N*/ sal_Bool bMapChanged = ImpCheckRefMapMode(); +/*N*/ +/*N*/ if ( pParaPortion->GetLines().Count() == 0 ) +/*N*/ { +/*N*/ EditLine* pL = new EditLine; +/*N*/ pParaPortion->GetLines().Insert( pL, 0 ); +/*N*/ } +/*N*/ +/*N*/ // --------------------------------------------------------------- +/*N*/ // Absatzattribute holen...... +/*N*/ // --------------------------------------------------------------- +/*N*/ ContentNode* const pNode = pParaPortion->GetNode(); +/*N*/ +/*N*/ BOOL bRightToLeftPara = IsRightToLeft( nPara ); +/*N*/ +/*N*/ SvxAdjust eJustification = GetJustification( nPara ); +/*N*/ sal_Bool bHyphenatePara = ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_HYPHENATE )).GetValue(); +/*N*/ const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pNode ); +/*N*/ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&) pNode->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ const BOOL bScriptSpace = ((const SvxScriptSpaceItem&) pNode->GetContentAttribs().GetItem( EE_PARA_ASIANCJKSPACING )).GetValue(); +/*N*/ +/*N*/ // const sal_uInt16 nInvalidEnd = ( pParaPortion->GetInvalidDiff() > 0 ) +/*N*/ // ? pParaPortion->GetInvalidPosStart() + pParaPortion->GetInvalidDiff() +/*N*/ // : pNode->Len(); +/*N*/ const short nInvalidDiff = pParaPortion->GetInvalidDiff(); +/*N*/ const sal_uInt16 nInvalidStart = pParaPortion->GetInvalidPosStart(); +/*N*/ const sal_uInt16 nInvalidEnd = nInvalidStart + Abs( nInvalidDiff ); +/*N*/ +/*N*/ sal_Bool bQuickFormat = sal_False; +/*N*/ if ( !bEmptyNodeWithPolygon && !HasScriptType( nPara, i18n::ScriptType::COMPLEX ) ) +/*N*/ { +/*N*/ if ( ( pParaPortion->IsSimpleInvalid() ) && ( nInvalidDiff > 0 ) && +/*N*/ ( pNode->Search( CH_FEATURE, nInvalidStart ) > nInvalidEnd ) ) +/*N*/ { +/*N*/ bQuickFormat = sal_True; +/*N*/ } +/*N*/ else if ( ( pParaPortion->IsSimpleInvalid() ) && ( nInvalidDiff < 0 ) ) +/*N*/ { +/*?*/ // pruefen, ob loeschen ueber Portiongrenzen erfolgte... +/*?*/ sal_uInt16 nStart = nInvalidStart; // DOPPELT !!!!!!!!!!!!!!! +/*?*/ sal_uInt16 nEnd = nStart - nInvalidDiff; // neg. +/*?*/ bQuickFormat = sal_True; +/*?*/ sal_uInt16 nPos = 0; +/*?*/ sal_uInt16 nPortions = pParaPortion->GetTextPortions().Count(); +/*?*/ for ( sal_uInt16 nTP = 0; nTP < nPortions; nTP++ ) +/*?*/ { +/*?*/ // Es darf kein Start/Ende im geloeschten Bereich liegen. +/*?*/ TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ]; +/*?*/ nPos += pTP->GetLen(); +/*?*/ if ( ( nPos > nStart ) && ( nPos < nEnd ) ) +/*?*/ { +/*?*/ bQuickFormat = sal_False; +/*?*/ break; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // SW disables TEXT_LAYOUT_COMPLEX_DISABLED, so maybe I have to enable it... +/*N*/ ULONG nOldLayoutMode = GetRefDevice()->GetLayoutMode(); +/*N*/ +/*N*/ ImplInitLayoutMode( GetRefDevice(), nPara, 0xFFFF ); +/*N*/ +/*N*/ sal_uInt16 nRealInvalidStart = nInvalidStart; +/*N*/ +/*N*/ if ( bEmptyNodeWithPolygon ) +/*N*/ { +/*?*/ TextPortion* pDummyPortion = new TextPortion( 0 ); +/*?*/ pParaPortion->GetTextPortions().Reset(); +/*?*/ pParaPortion->GetTextPortions().Insert( pDummyPortion, 0 ); +/*N*/ } +/*N*/ else if ( bQuickFormat ) +/*N*/ { +/*N*/ // schnellere Methode: +/*N*/ RecalcTextPortion( pParaPortion, nInvalidStart, nInvalidDiff ); +/*N*/ } +/*N*/ else // nRealInvalidStart kann vor InvalidStart liegen, weil Portions geloescht.... +/*N*/ { +/*N*/ CreateTextPortions( pParaPortion, nRealInvalidStart ); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // --------------------------------------------------------------- +/*N*/ // Zeile mit InvalidPos suchen, eine Zeile davor beginnen... +/*N*/ // Zeilen flaggen => nicht removen ! +/*N*/ // --------------------------------------------------------------- +/*N*/ +/*N*/ sal_uInt16 nLine = pParaPortion->GetLines().Count()-1; +/*N*/ for ( sal_uInt16 nL = 0; nL <= nLine; nL++ ) +/*N*/ { +/*N*/ EditLine* pLine = pParaPortion->GetLines().GetObject( nL ); +/*N*/ if ( pLine->GetEnd() > nRealInvalidStart ) // nicht nInvalidStart! +/*N*/ { +/*N*/ nLine = nL; +/*N*/ break; +/*N*/ } +/*N*/ pLine->SetValid(); +/*N*/ } +/*N*/ // Eine Zeile davor beginnen... +/*N*/ // Wenn ganz hinten getippt wird, kann sich die Zeile davor nicht aendern. +/*N*/ if ( nLine && ( !pParaPortion->IsSimpleInvalid() || ( nInvalidEnd < pNode->Len() ) || ( nInvalidDiff <= 0 ) ) ) +/*N*/ nLine--; +/*N*/ +/*N*/ EditLine* pLine = pParaPortion->GetLines().GetObject( nLine ); +/*N*/ +/*N*/ static Rectangle aZeroArea = Rectangle( Point(), Point() ); +/*N*/ Rectangle aBulletArea( aZeroArea ); +/*N*/ if ( !nLine ) +/*N*/ { +/*N*/ aBulletArea = GetEditEnginePtr()->GetBulletArea( GetParaPortions().GetPos( pParaPortion ) ); +/*N*/ if ( aBulletArea.Right() > 0 ) +/*N*/ pParaPortion->SetBulletX( (sal_uInt16) GetXValue( aBulletArea.Right() ) ); +/*N*/ else +/*N*/ pParaPortion->SetBulletX( 0 ); // Falls Bullet falsch eingestellt. +/*N*/ } +/*N*/ +/*N*/ // --------------------------------------------------------------- +/*N*/ // Ab hier alle Zeilen durchformatieren... +/*N*/ // --------------------------------------------------------------- +/*N*/ sal_uInt16 nDelFromLine = 0xFFFF; +/*N*/ sal_Bool bLineBreak = sal_False; +/*N*/ +/*N*/ sal_uInt16 nIndex = pLine->GetStart(); +/*N*/ EditLine aSaveLine( *pLine ); +/*N*/ SvxFont aTmpFont( pNode->GetCharAttribs().GetDefFont() ); +/*N*/ +/*N*/ sal_Bool bCalcCharPositions = sal_True; +/*N*/ sal_Int32* pBuf = new sal_Int32[ pNode->Len() ]; +/*N*/ +/*N*/ sal_Bool bSameLineAgain = sal_False; // Fuer TextRanger, wenn sich die Hoehe aendert. +/*N*/ TabInfo aCurrentTab; +/*N*/ +/*N*/ BOOL bForceOneRun = bEmptyNodeWithPolygon; +/*N*/ BOOL bCompressedChars = FALSE; +/*N*/ +/*N*/ while ( ( nIndex < pNode->Len() ) || bForceOneRun ) +/*N*/ { +/*N*/ bForceOneRun = FALSE; +/*N*/ +/*N*/ sal_Bool bEOL = sal_False; +/*N*/ sal_Bool bEOC = sal_False; +/*N*/ sal_uInt16 nPortionStart = 0; +/*N*/ sal_uInt16 nPortionEnd = 0; +/*N*/ +/*N*/ long nStartX = GetXValue( rLRItem.GetTxtLeft() ); +/*N*/ if ( nIndex == 0 ) +/*N*/ { +/*N*/ long nFI = GetXValue( rLRItem.GetTxtFirstLineOfst() ); +/*N*/ nStartX += nFI; +/*N*/ +/*N*/ if ( !nLine && ( pParaPortion->GetBulletX() > nStartX ) ) +/*N*/ { +/*N*/ nStartX -= nFI; // Vielleicht reicht der LI? +/*N*/ if ( pParaPortion->GetBulletX() > nStartX ) +/*N*/ nStartX = pParaPortion->GetBulletX(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ long nMaxLineWidth; +/*N*/ if ( !IsVertical() ) +/*N*/ nMaxLineWidth = aStatus.AutoPageWidth() ? aMaxAutoPaperSize.Width() : aPaperSize.Width(); +/*N*/ else +/*?*/ nMaxLineWidth = aStatus.AutoPageHeight() ? aMaxAutoPaperSize.Height() : aPaperSize.Height(); +/*N*/ +/*N*/ nMaxLineWidth -= GetXValue( rLRItem.GetRight() ); +/*N*/ nMaxLineWidth -= nStartX; +/*N*/ +/*N*/ // Wenn PaperSize == long_max, kann ich keinen neg. Erstzeileneinzug +/*N*/ // abziehen (Overflow) +/*N*/ if ( ( nMaxLineWidth < 0 ) && ( nStartX < 0 ) ) +/*?*/ nMaxLineWidth = ( !IsVertical() ? aPaperSize.Width() : aPaperSize.Height() ) - GetXValue( rLRItem.GetRight() ); +/*N*/ +/*N*/ // Wenn jetzt noch kleiner 0, kann es nur der rechte Rand sein. +/*N*/ if ( nMaxLineWidth <= 0 ) +/*?*/ nMaxLineWidth = 1; +/*N*/ +/*N*/ // Problem: Da eine Zeile _vor_ der ungueltigen Position mit der +/*N*/ // Formatierung begonnen wird, werden hier leider auch die Positionen +/*N*/ // neu bestimmt... +/*N*/ // Loesungsansatz: +/*N*/ // Die Zeile davor kann nur groesser werden, nicht kleiner +/*N*/ // => ... +/*N*/ if ( bCalcCharPositions ) +/*N*/ pLine->GetCharPosArray().Remove( 0, pLine->GetCharPosArray().Count() ); +/*N*/ +/*N*/ sal_uInt16 nTmpPos = nIndex; +/*N*/ sal_uInt16 nTmpPortion = pLine->GetStartPortion(); +/*N*/ long nTmpWidth = 0; +/*N*/ long nXWidth = nMaxLineWidth; +/*N*/ if ( nXWidth <= nTmpWidth ) // while muss 1x durchlaufen werden +/*?*/ nXWidth = nTmpWidth+1; +/*N*/ +/*N*/ SvLongsPtr pTextRanges = 0; +/*N*/ long nTextExtraYOffset = 0; +/*N*/ long nTextXOffset = 0; +/*N*/ long nTextLineHeight = 0; +/*N*/ if ( GetTextRanger() ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 GetTextRanger()->SetVertical( IsVertical() ); +/*N*/ } +/*N*/ +/*N*/ // Portion suchen, die nicht mehr in Zeile passt.... +/*N*/ TextPortion* pPortion; +/*N*/ sal_Bool bBrokenLine = sal_False; +/*N*/ bLineBreak = sal_False; +/*N*/ EditCharAttrib* pNextFeature = pNode->GetCharAttribs().FindFeature( pLine->GetStart() ); +/*N*/ while ( ( nTmpWidth < nXWidth ) && !bEOL && ( nTmpPortion < pParaPortion->GetTextPortions().Count() ) ) +/*N*/ { +/*N*/ nPortionStart = nTmpPos; +/*N*/ pPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*N*/ if ( pPortion->GetKind() == PORTIONKIND_HYPHENATOR ) +/*N*/ { +/*?*/ // Portion wegschmeissen, ggf. die davor korrigieren, wenn +/*?*/ // die Hyph-Portion ein Zeichen geschluckt hat... +/*?*/ pParaPortion->GetTextPortions().Remove( nTmpPortion ); +/*?*/ if ( nTmpPortion && pPortion->GetLen() ) +/*?*/ { +/*?*/ nTmpPortion--; +/*?*/ TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*?*/ DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); +/*?*/ nTmpWidth -= pPrev->GetSize().Width(); +/*?*/ nTmpPos -= pPrev->GetLen(); +/*?*/ pPrev->SetLen( pPrev->GetLen() + pPortion->GetLen() ); +/*?*/ pPrev->GetSize().Width() = (-1); +/*?*/ } +/*?*/ delete pPortion; +/*?*/ DBG_ASSERT( nTmpPortion < pParaPortion->GetTextPortions().Count(), "Keine Portion mehr da!" ); +/*?*/ pPortion = pParaPortion->GetTextPortions().GetObject( nTmpPortion ); +/*N*/ } +/*N*/ DBG_ASSERT( pPortion->GetKind() != PORTIONKIND_HYPHENATOR, "CreateLines: Hyphenator-Portion!" ); +/*N*/ DBG_ASSERT( pPortion->GetLen() || bProcessingEmptyLine, "Leere Portion in CreateLines ?!" ); +/*N*/ if ( pNextFeature && ( pNextFeature->GetStart() == nTmpPos ) ) +/*N*/ { +/*N*/ sal_uInt16 nWhich = pNextFeature->GetItem()->Which(); +/*N*/ switch ( nWhich ) +/*N*/ { +/*N*/ case EE_FEATURE_TAB: +/*N*/ { +/*N*/ long nOldTmpWidth = nTmpWidth; +/*N*/ +/*N*/ // Tab-Pos suchen... +/*N*/ long nCurPos = nTmpWidth+nStartX; +/*N*/ // nCurPos -= rLRItem.GetTxtLeft(); // Tabs relativ zu LI +/*N*/ // Skalierung rausrechnen +/*N*/ if ( aStatus.DoStretch() && ( nStretchX != 100 ) ) +/*?*/ nCurPos = nCurPos*100/nStretchX; +/*N*/ +/*N*/ aCurrentTab.aTabStop = pNode->GetContentAttribs().FindTabStop( nCurPos - rLRItem.GetTxtLeft(), aEditDoc.GetDefTab() ); +/*N*/ aCurrentTab.nTabPos = GetXValue( (long) ( aCurrentTab.aTabStop.GetTabPos() + rLRItem.GetTxtLeft() ) ); +/*N*/ aCurrentTab.bValid = FALSE; +/*N*/ +/*N*/ // Switch direction in R2L para... +/*N*/ if ( bRightToLeftPara ) +/*N*/ { +/*?*/ if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_RIGHT ) +/*?*/ aCurrentTab.aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; +/*?*/ else if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_LEFT ) +/*?*/ aCurrentTab.aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; +/*N*/ } +/*N*/ +/*N*/ if ( ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_RIGHT ) || +/*N*/ ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_CENTER ) || +/*N*/ ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_DECIMAL ) ) +/*N*/ { +/*N*/ // Bei LEFT/DEFAULT wird dieses Tab nicht mehr betrachtet. +/*N*/ aCurrentTab.bValid = TRUE; +/*N*/ aCurrentTab.nStartPosX = nTmpWidth; +/*N*/ aCurrentTab.nCharPos = nTmpPos; +/*N*/ aCurrentTab.nTabPortion = nTmpPortion; +/*N*/ } +/*N*/ +/*N*/ pPortion->GetKind() = PORTIONKIND_TAB; +/*N*/ pPortion->SetExtraValue( aCurrentTab.aTabStop.GetFill() ); +/*N*/ pPortion->GetSize().Width() = aCurrentTab.nTabPos - (nTmpWidth+nStartX); +/*N*/ +/*N*/ // #90520# Height needed... +/*N*/ SeekCursor( pNode, nTmpPos+1, aTmpFont ); +/*N*/ pPortion->GetSize().Height() = aTmpFont.QuickGetTextSize( GetRefDevice(), String(), 0, 0, NULL ).Height(); +/*N*/ +/*N*/ DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab falsch berechnet!" ); +/*N*/ +/*N*/ nTmpWidth = aCurrentTab.nTabPos-nStartX; +/*N*/ +/*N*/ // Wenn dies das erste Token in der Zeile ist, +/*N*/ // und nTmpWidth > aPaperSize.Width, habe ich eine +/*N*/ // Endlos-Schleife! +/*N*/ if ( ( nTmpWidth >= nXWidth ) && ( nTmpPortion == pLine->GetStartPortion() ) ) +/*N*/ { +/*?*/ // Aber was jetzt ? +/*?*/ // Tab passend machen +/*?*/ pPortion->GetSize().Width() = nXWidth-nOldTmpWidth; +/*?*/ nTmpWidth = nXWidth-1; +/*?*/ bEOL = sal_True; +/*?*/ bBrokenLine = sal_True; +/*N*/ } +/*N*/ pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); +/*N*/ bCompressedChars = FALSE; +/*N*/ } +/*N*/ break; +/*N*/ case EE_FEATURE_LINEBR: +/*N*/ { +/*N*/ DBG_ASSERT( pPortion, "?!" ); +/*N*/ pPortion->GetSize().Width() = 0; +/*N*/ bEOL = sal_True; +/*N*/ bLineBreak = sal_True; +/*N*/ pPortion->GetKind() = PORTIONKIND_LINEBREAK; +/*N*/ bCompressedChars = FALSE; +/*N*/ pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); +/*N*/ } +/*N*/ break; +/*N*/ case EE_FEATURE_FIELD: +/*N*/ { +/*N*/ long nCurWidth = nTmpWidth; +/*N*/ SeekCursor( pNode, nTmpPos+1, aTmpFont ); +/*N*/ sal_Unicode cChar = 0; // later: NBS? +/*N*/ aTmpFont.SetPhysFont( GetRefDevice() ); +/*N*/ String aFieldValue = cChar ? String(cChar) : ((EditCharAttribField*)pNextFeature)->GetFieldValue(); +/*N*/ if ( bCalcCharPositions || !pPortion->HasValidSize() ) +/*N*/ { +/*N*/ pPortion->GetSize() = aTmpFont.QuickGetTextSize( GetRefDevice(), aFieldValue, 0, aFieldValue.Len(), 0 ); +/*N*/ // Damit kein Scrollen bei ueberlangen Feldern +/*N*/ if ( pPortion->GetSize().Width() > nXWidth ) +/*?*/ pPortion->GetSize().Width() = nXWidth; +/*N*/ } +/*N*/ nTmpWidth += pPortion->GetSize().Width(); +/*N*/ pLine->GetCharPosArray().Insert( pPortion->GetSize().Width(), nTmpPos-pLine->GetStart() ); +/*N*/ pPortion->GetKind() = cChar ? PORTIONKIND_TEXT : PORTIONKIND_FIELD; +/*N*/ // Wenn dies das erste Token in der Zeile ist, +/*N*/ // und nTmpWidth > aPaperSize.Width, habe ich eine +/*N*/ // Endlos-Schleife! +/*N*/ if ( ( nTmpWidth >= nXWidth ) && ( nTmpPortion == pLine->GetStartPortion() ) ) +/*N*/ { +/*?*/ nTmpWidth = nXWidth-1; +/*?*/ bEOL = sal_True; +/*?*/ bBrokenLine = sal_True; +/*N*/ } +/*N*/ // Compression in Fields???? +/*N*/ // I think this could be a little bit difficult and is not very usefull +/*N*/ bCompressedChars = FALSE; +/*N*/ } +/*N*/ break; +/*N*/ default: DBG_ERROR( "Was fuer ein Feature ?" ); +/*N*/ } +/*N*/ pNextFeature = pNode->GetCharAttribs().FindFeature( pNextFeature->GetStart() + 1 ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ASSERT( pPortion->GetLen() || bProcessingEmptyLine, "Empty Portion - Extra Space?!" ); +/*N*/ SeekCursor( pNode, nTmpPos+1, aTmpFont ); +/*N*/ aTmpFont.SetPhysFont( GetRefDevice() ); +/*N*/ if ( bCalcCharPositions || !pPortion->HasValidSize() ) +/*N*/ pPortion->GetSize() = aTmpFont.QuickGetTextSize( GetRefDevice(), *pParaPortion->GetNode(), nTmpPos, pPortion->GetLen(), pBuf ); +/*N*/ +/*N*/ if ( bCalcCharPositions ) +/*N*/ { +/*N*/ sal_uInt16 nLen = pPortion->GetLen(); +/*N*/ // Es wird am Anfang generell das Array geplaettet +/*N*/ // => Immer einfach schnelles insert. +/*N*/ sal_uInt16 nPos = nTmpPos - pLine->GetStart(); +/*N*/ pLine->GetCharPosArray().Insert( pBuf, nLen, nPos ); +/*N*/ } +/*N*/ +/*N*/ // And now check for Compression: +/*N*/ if ( pPortion->GetLen() && GetAsianCompressionMode() ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 bCompressedChars |= ImplCalcAsianCompression( pNode, pPortion, nTmpPos, (long*)pLine->GetCharPosArray().GetData() + (nTmpPos-pLine->GetStart()), 10000, FALSE ); +/*N*/ +/*N*/ nTmpWidth += pPortion->GetSize().Width(); +/*N*/ +/*N*/ pPortion->SetRightToLeft( GetRightToLeft( nPara, nTmpPos+1 ) ); +/*N*/ +/*N*/ USHORT nPortionEnd = nTmpPos + pPortion->GetLen(); +/*N*/ if( bScriptSpace && ( nPortionEnd < pNode->Len() ) && ( nTmpWidth < nXWidth ) && IsScriptChange( EditPaM( pNode, nPortionEnd ) ) ) +/*N*/ { +/*N*/ BOOL bAllow = FALSE; +/*N*/ USHORT nScriptTypeLeft = GetScriptType( EditPaM( pNode, nPortionEnd ) ); +/*N*/ USHORT nScriptTypeRight = GetScriptType( EditPaM( pNode, nPortionEnd+1 ) ); +/*N*/ if ( ( nScriptTypeLeft == i18n::ScriptType::ASIAN ) || ( nScriptTypeRight == i18n::ScriptType::ASIAN ) ) +/*N*/ bAllow = TRUE; +/*N*/ +/*N*/ // No spacing within L2R/R2L nesting +/*N*/ if ( bAllow ) +/*N*/ { +/*?*/ long nExtraSpace = pPortion->GetSize().Height()/5; +/*?*/ nExtraSpace = GetXValue( nExtraSpace ); +/*?*/ pPortion->GetSize().Width() += nExtraSpace; +/*?*/ nTmpWidth += nExtraSpace; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( aCurrentTab.bValid && ( nTmpPortion != aCurrentTab.nTabPortion ) ) +/*N*/ { +/*N*/ long nWidthAfterTab = 0; +/*N*/ for ( USHORT n = aCurrentTab.nTabPortion+1; n <= nTmpPortion; n++ ) +/*N*/ { +/*N*/ TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( n ); +/*N*/ nWidthAfterTab += pTP->GetSize().Width(); +/*N*/ } +/*N*/ long nW; // Length before tab position +/*N*/ if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_RIGHT ) +/*N*/ { +/*N*/ nW = nWidthAfterTab; +/*N*/ } +/*N*/ else if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_CENTER ) +/*N*/ { +/*?*/ nW = nWidthAfterTab/2; +/*N*/ } +/*N*/ else if ( aCurrentTab.aTabStop.GetAdjustment() == SVX_TAB_ADJUST_DECIMAL ) +/*N*/ { +/*?*/ nW = nWidthAfterTab; +/*?*/ String aText = GetSelected( EditSelection( EditPaM( pParaPortion->GetNode(), nTmpPos ), +/*?*/ EditPaM( pParaPortion->GetNode(), nTmpPos + pPortion->GetLen() ) ) ); +/*?*/ USHORT nDecPos = aText.Search( aCurrentTab.aTabStop.GetDecimal() ); +/*?*/ if ( nDecPos != STRING_NOTFOUND ) +/*?*/ { +/*?*/ nW -= pParaPortion->GetTextPortions().GetObject( nTmpPortion )->GetSize().Width(); +/*?*/ nW += aTmpFont.QuickGetTextSize( GetRefDevice(), *pParaPortion->GetNode(), nTmpPos, nDecPos, NULL ).Width(); +/*?*/ aCurrentTab.bValid = FALSE; +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ DBG_ERROR( "CreateLines: Tab not handled!" ); +/*N*/ } +/*N*/ long nMaxW = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nStartX; +/*N*/ if ( nW >= nMaxW ) +/*N*/ { +/*?*/ nW = nMaxW; +/*?*/ aCurrentTab.bValid = FALSE; +/*N*/ } +/*N*/ TextPortion* pTabPortion = pParaPortion->GetTextPortions().GetObject( aCurrentTab.nTabPortion ); +/*N*/ pTabPortion->GetSize().Width() = aCurrentTab.nTabPos - aCurrentTab.nStartPosX - nW - nStartX; +/*N*/ nTmpWidth = aCurrentTab.nStartPosX + pTabPortion->GetSize().Width() + nWidthAfterTab; +/*N*/ } +/*N*/ +/*N*/ nTmpPos += pPortion->GetLen(); +/*N*/ nPortionEnd = nTmpPos; +/*N*/ nTmpPortion++; +/*N*/ if ( aStatus.OneCharPerLine() ) +/*N*/ bEOL = sal_True; +/*N*/ } +/*N*/ +/*N*/ aCurrentTab.bValid = FALSE; +/*N*/ +/*N*/ // das war evtl. eine Portion zu weit: +/*N*/ sal_Bool bFixedEnd = sal_False; +/*N*/ if ( aStatus.OneCharPerLine() ) +/*N*/ { +/*?*/ // Zustand vor Portion: ( bis auf nTmpWidth ) +/*?*/ nPortionEnd = nTmpPos; +/*?*/ nTmpPos -= pPortion->GetLen(); +/*?*/ nPortionStart = nTmpPos; +/*?*/ nTmpPortion--; +/*?*/ +/*?*/ bEOL = sal_True; +/*?*/ bEOC = sal_False; +/*?*/ +/*?*/ // Und jetzt genau ein Zeichen: +/*?*/ nTmpPos++; +/*?*/ nTmpPortion++; +/*?*/ nPortionEnd = nTmpPortion; +/*?*/ // Eine Nicht-Feature-Portion muss gebrochen werden +/*?*/ if ( pPortion->GetLen() > 1 ) +/*?*/ { +/*?*/ DBG_ASSERT( pPortion->GetKind() == PORTIONKIND_TEXT, "Len>1, aber keine TextPortion?" ); +/*?*/ nTmpWidth -= pPortion->GetSize().Width(); +/*?*/ sal_uInt16 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine ); +/*?*/ TextPortion* p = pParaPortion->GetTextPortions().GetObject( nP ); +/*?*/ DBG_ASSERT( p, "Portion ?!" ); +/*?*/ nTmpWidth += p->GetSize().Width(); +/*?*/ } +/*N*/ } +/*N*/ else if ( nTmpWidth >= nXWidth ) +/*N*/ { +/*N*/ nPortionEnd = nTmpPos; +/*N*/ nTmpPos -= pPortion->GetLen(); +/*N*/ nPortionStart = nTmpPos; +/*N*/ nTmpPortion--; +/*N*/ bEOL = sal_False; +/*N*/ bEOC = sal_False; +/*N*/ switch ( pPortion->GetKind() ) +/*N*/ { +/*N*/ case PORTIONKIND_TEXT: +/*N*/ { +/*N*/ nTmpWidth -= pPortion->GetSize().Width(); +/*N*/ } +/*N*/ break; +/*N*/ case PORTIONKIND_FIELD: +/*N*/ case PORTIONKIND_TAB: +/*N*/ { +/*?*/ nTmpWidth -= pPortion->GetSize().Width(); +/*?*/ bEOL = sal_True; +/*?*/ bFixedEnd = sal_True; +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ { +/*?*/ // Ein Feature wird nicht umgebrochen: +/*?*/ DBG_ASSERT( ( pPortion->GetKind() == PORTIONKIND_LINEBREAK ), "Was fuer ein Feature ?" ); +/*?*/ bEOL = sal_True; +/*?*/ bFixedEnd = sal_True; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ bEOL = sal_True; +/*N*/ bEOC = sal_True; +/*N*/ pLine->SetEnd( nPortionEnd ); +/*N*/ DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "Keine TextPortions?" ); +/*N*/ pLine->SetEndPortion( (sal_uInt16)pParaPortion->GetTextPortions().Count() - 1 ); +/*N*/ } +/*N*/ +/*N*/ if ( aStatus.OneCharPerLine() ) +/*N*/ { +/*?*/ pLine->SetEnd( nPortionEnd ); +/*?*/ pLine->SetEndPortion( nTmpPortion-1 ); +/*N*/ } +/*N*/ else if ( bFixedEnd ) +/*N*/ { +/*N*/ pLine->SetEnd( nPortionStart ); +/*N*/ pLine->SetEndPortion( nTmpPortion-1 ); +/*N*/ } +/*N*/ else if ( bLineBreak || bBrokenLine ) +/*N*/ { +/*N*/ pLine->SetEnd( nPortionStart+1 ); +/*N*/ pLine->SetEndPortion( nTmpPortion-1 ); +/*N*/ bEOC = sal_False; // wurde oben gesetzt, vielleich mal die if's umstellen? +/*N*/ } +/*N*/ else if ( !bEOL ) +/*N*/ { +/*N*/ DBG_ASSERT( (nPortionEnd-nPortionStart) == pPortion->GetLen(), "Doch eine andere Portion?!" ); +/*N*/ long nRemainingWidth = nMaxLineWidth - nTmpWidth; +/*N*/ sal_Bool bCanHyphenate = ( aTmpFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL ); +/*N*/ if ( bCompressedChars && ( pPortion->GetLen() > 1 ) && pPortion->GetExtraInfos() && pPortion->GetExtraInfos()->bCompressed ) +/*N*/ { +/*?*/ // I need the manipulated DXArray for determining the break postion... +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ImplCalcAsianCompression( pNode, pPortion, nPortionStart, (long*)pLine->GetCharPosArray().GetData() + (nPortionStart-pLine->GetStart()), 10000, TRUE ); +/*N*/ } +/*N*/ ImpBreakLine( pParaPortion, pLine, pPortion, nPortionStart, +/*N*/ nRemainingWidth, bCanHyphenate && bHyphenatePara ); +/*N*/ } +/*N*/ +/*N*/ // ------------------------------------------------------------------ +/*N*/ // Zeile fertig => justieren +/*N*/ // ------------------------------------------------------------------ +/*N*/ +/*N*/ // CalcTextSize sollte besser durch ein kontinuierliches +/*N*/ // Registrieren ersetzt werden ! +/*N*/ Size aTextSize = pLine->CalcTextSize( *pParaPortion ); +/*N*/ +/*N*/ if ( aTextSize.Height() == 0 ) +/*N*/ { +/*?*/ SeekCursor( pNode, pLine->GetStart()+1, aTmpFont ); +/*?*/ aTmpFont.SetPhysFont( pRefDev ); +/*?*/ aTextSize.Height() = aTmpFont.GetPhysTxtSize( pRefDev, String() ).Height(); +/*?*/ pLine->SetHeight( (sal_uInt16)aTextSize.Height() ); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // Die Fontmetriken koennen nicht kontinuierlich berechnet werden, +/*N*/ // wenn der Font sowieso eingestellt ist, weil ggf. ein grosser Font +/*N*/ // erst nach dem Umbrechen ploetzlich in der naechsten Zeile landet +/*N*/ // => Font-Metriken zu gross. +/*N*/ FormatterFontMetric aFormatterMetrics; +/*N*/ sal_uInt16 nTPos = pLine->GetStart(); +/*N*/ for ( sal_uInt16 nP = pLine->GetStartPortion(); nP <= pLine->GetEndPortion(); nP++ ) +/*N*/ { +/*N*/ TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( nP ); +/*N*/ // #95819# problem with hard font height attribute, when everthing but the line break has this attribute +/*N*/ if ( pTP->GetKind() != PORTIONKIND_LINEBREAK ) +/*N*/ { +/*N*/ SeekCursor( pNode, nTPos+1, aTmpFont ); +/*N*/ aTmpFont.SetPhysFont( GetRefDevice() ); +/*N*/ RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont ); +/*N*/ } +/*N*/ nTPos += pTP->GetLen(); +/*N*/ } +/*N*/ sal_uInt16 nLineHeight = aFormatterMetrics.GetHeight(); +/*N*/ if ( nLineHeight > pLine->GetHeight() ) +/*N*/ pLine->SetHeight( nLineHeight ); +/*N*/ pLine->SetMaxAscent( aFormatterMetrics.nMaxAscent ); +/*N*/ +/*N*/ bSameLineAgain = sal_False; +/*N*/ if ( GetTextRanger() && ( pLine->GetHeight() > nTextLineHeight ) ) +/*N*/ { +/*N*/ // Nochmal mit der anderen Groesse aufsetzen! +/*?*/ bSameLineAgain = sal_True; +/*N*/ } +/*N*/ +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ if ( rLSItem.GetLineSpaceRule() == SVX_LINE_SPACE_MIN ) +/*N*/ { +/*?*/ sal_uInt16 nMinHeight = GetYValue( rLSItem.GetLineHeight() ); +/*?*/ sal_uInt16 nTxtHeight = pLine->GetHeight(); +/*?*/ if ( nTxtHeight < nMinHeight ) +/*?*/ { +/*?*/ // Der Ascent muss um die Differenz angepasst werden: +/*?*/ long nDiff = nMinHeight - nTxtHeight; +/*?*/ pLine->SetMaxAscent( (sal_uInt16)(pLine->GetMaxAscent() + nDiff) ); +/*?*/ pLine->SetHeight( nMinHeight, nTxtHeight ); +/*?*/ } +/*N*/ } +/*N*/ else if ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) +/*N*/ { +/*N*/ if ( nPara || ( pLine->GetStartPortion() != 0 ) ) // Nicht die aller erste Zeile +/*N*/ { +/*N*/ // #100508# There are documents with PropLineSpace 0, why? +/*N*/ if ( rLSItem.GetPropLineSpace() && ( rLSItem.GetPropLineSpace() != 100 ) ) +/*N*/ { +/*N*/ sal_uInt16 nTxtHeight = pLine->GetHeight(); +/*N*/ sal_uInt32 nH = nTxtHeight; +/*N*/ nH *= rLSItem.GetPropLineSpace(); +/*N*/ nH /= 100; +/*N*/ // Der Ascent muss um die Differenz angepasst werden: +/*N*/ long nDiff = pLine->GetHeight() - nH; +/*N*/ if ( nDiff > pLine->GetMaxAscent() ) +/*?*/ nDiff = pLine->GetMaxAscent(); +/*N*/ pLine->SetMaxAscent( (sal_uInt16)(pLine->GetMaxAscent() - nDiff) ); +/*N*/ pLine->SetHeight( (sal_uInt16)nH, nTxtHeight ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // #80582# - Bullet should not influence line height +/*N*/ // if ( !nLine ) +/*N*/ // { +/*N*/ // long nBulletHeight = aBulletArea.GetHeight(); +/*N*/ // if ( nBulletHeight > (long)pLine->GetHeight() ) +/*N*/ // { +/*N*/ // long nDiff = nBulletHeight - (long)pLine->GetHeight(); +/*N*/ // // nDiff auf oben und unten verteilen. +/*N*/ // pLine->SetMaxAscent( (sal_uInt16)(pLine->GetMaxAscent() + nDiff/2) ); +/*N*/ // pLine->SetHeight( (sal_uInt16)nBulletHeight ); +/*N*/ // } +/*N*/ // } +/*N*/ +/*N*/ if ( ( !IsVertical() && aStatus.AutoPageWidth() ) || +/*N*/ ( IsVertical() && aStatus.AutoPageHeight() ) ) +/*N*/ { +/*N*/ // Wenn die Zeile in die aktuelle Papierbreite passt, muss +/*N*/ // diese Breite fuer die Ausrichting verwendet werden. +/*N*/ // Wenn sie nicht passt oder sie die Papierbreite aendert, +/*N*/ // wird bei Justification != LEFT sowieso noch mal formatiert. +/*N*/ long nMaxLineWidthFix = ( !IsVertical() ? aPaperSize.Width() : aPaperSize.Height() ) +/*N*/ - GetXValue( rLRItem.GetRight() ) - nStartX; +/*N*/ if ( aTextSize.Width() < nMaxLineWidthFix ) +/*N*/ nMaxLineWidth = nMaxLineWidthFix; +/*N*/ } +/*N*/ +/*N*/ if ( bCompressedChars ) +/*N*/ { +/*?*/ long nRemainingWidth = nMaxLineWidth - aTextSize.Width(); +/*?*/ if ( nRemainingWidth > 0 ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 ImplExpandCompressedPortions( pLine, pParaPortion, nRemainingWidth ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pLine->IsHangingPunctuation() ) +/*N*/ { +/*?*/ // Width from HangingPunctuation was set to 0 in ImpBreakLine, +/*?*/ // check for rel width now, maybe create compression... +/*?*/ long n = nMaxLineWidth - aTextSize.Width(); +/*?*/ TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( pLine->GetEndPortion() ); +/*?*/ sal_uInt16 nPosInArray = pLine->GetEnd()-1-pLine->GetStart(); +/*?*/ long nNewValue = ( nPosInArray ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 ) + n; +/*?*/ pLine->GetCharPosArray()[ nPosInArray ] = nNewValue; +/*?*/ pTP->GetSize().Width() += n; +/*N*/ } +/*N*/ +/*N*/ pLine->SetTextWidth( aTextSize.Width() ); +/*N*/ switch ( eJustification ) +/*N*/ { +/*N*/ case SVX_ADJUST_CENTER: +/*N*/ { +/*N*/ long n = ( nMaxLineWidth - aTextSize.Width() ) / 2; +/*N*/ n += nStartX; // Einrueckung bleibt erhalten. +/*N*/ if ( n > 0 ) +/*N*/ pLine->SetStartPosX( (sal_uInt16)n ); +/*N*/ else +/*N*/ pLine->SetStartPosX( 0 ); +/*N*/ +/*N*/ } +/*N*/ break; +/*N*/ case SVX_ADJUST_RIGHT: +/*N*/ { +/*N*/ // Bei automatisch umgebrochenen Zeilen, die ein Blank +/*N*/ // am Ende enthalten, darf das Blank nicht ausgegeben werden! +/*N*/ +/*N*/ long n = nMaxLineWidth - aTextSize.Width(); +/*N*/ n += nStartX; // Einrueckung bleibt erhalten. +/*N*/ if ( n > 0 ) +/*N*/ pLine->SetStartPosX( (sal_uInt16)n ); +/*N*/ else +/*?*/ pLine->SetStartPosX( 0 ); +/*N*/ } +/*N*/ break; +/*N*/ case SVX_ADJUST_BLOCK: +/*N*/ { +/*N*/ long nRemainingSpace = nMaxLineWidth - aTextSize.Width(); +/*N*/ pLine->SetStartPosX( (sal_uInt16)nStartX ); +/*N*/ if ( !bEOC && ( nRemainingSpace > 0 ) ) // nicht die letzte Zeile... +/*N*/ ImpAdjustBlocks( pParaPortion, pLine, nRemainingSpace ); +/*N*/ } +/*N*/ break; +/*N*/ default: +/*N*/ { +/*N*/ pLine->SetStartPosX( (sal_uInt16)nStartX ); // FI, LI +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ // ----------------------------------------------------------------- +/*N*/ // pruefen, ob die Zeile neu ausgegeben werden muss... +/*N*/ // ----------------------------------------------------------------- +/*N*/ pLine->SetInvalid(); +/*N*/ +/*N*/ // Wenn eine Portion umgebrochen wurde sind ggf. viel zu viele Positionen +/*N*/ // im CharPosArray: +/*N*/ if ( bCalcCharPositions ) +/*N*/ { +/*N*/ sal_uInt16 nLen = pLine->GetLen(); +/*N*/ sal_uInt16 nCount = pLine->GetCharPosArray().Count(); +/*N*/ if ( nCount > nLen ) +/*N*/ pLine->GetCharPosArray().Remove( nLen, nCount-nLen ); +/*N*/ } +/*N*/ +/*N*/ if ( GetTextRanger() ) +/*N*/ { +/*?*/ if ( nTextXOffset ) +/*?*/ pLine->SetStartPosX( (sal_uInt16) ( pLine->GetStartPosX() + nTextXOffset ) ); +/*?*/ if ( nTextExtraYOffset ) +/*?*/ { +/*?*/ pLine->SetHeight( (sal_uInt16) ( pLine->GetHeight() + nTextExtraYOffset ), 0, pLine->GetHeight() ); +/*?*/ pLine->SetMaxAscent( (sal_uInt16) ( pLine->GetMaxAscent() + nTextExtraYOffset ) ); +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ // Fuer kleiner 0 noch ueberlegen! +/*N*/ if ( pParaPortion->IsSimpleInvalid() /* && ( nInvalidDiff > 0 ) */ ) +/*N*/ { +/*N*/ // Aenderung durch einfache Textaenderung... +/*N*/ // Formatierung nicht abbrechen, da Portions evtl. wieder +/*N*/ // gesplittet werden muessen! +/*N*/ // Wenn irgendwann mal abbrechbar, dann fogende Zeilen Validieren! +/*N*/ // Aber ggf. als Valid markieren, damit weniger Ausgabe... +/*N*/ if ( pLine->GetEnd() < nInvalidStart ) +/*N*/ { +/*?*/ if ( *pLine == aSaveLine ) +/*?*/ { +/*?*/ pLine->SetValid(); +/*?*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ sal_uInt16 nStart = pLine->GetStart(); +/*N*/ sal_uInt16 nEnd = pLine->GetEnd(); +/*N*/ +/*N*/ if ( nStart > nInvalidEnd ) +/*N*/ { +/*?*/ if ( ( ( nStart-nInvalidDiff ) == aSaveLine.GetStart() ) && +/*?*/ ( ( nEnd-nInvalidDiff ) == aSaveLine.GetEnd() ) ) +/*?*/ { +/*?*/ pLine->SetValid(); +/*?*/ if ( bCalcCharPositions && bQuickFormat ) +/*?*/ { +/*?*/ bCalcCharPositions = sal_False; +/*?*/ bLineBreak = sal_False; +/*?*/ pParaPortion->CorrectValuesBehindLastFormattedLine( nLine ); +/*?*/ break; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else if ( bCalcCharPositions && bQuickFormat && ( nEnd > nInvalidEnd) ) +/*N*/ { +/*N*/ // Wenn die ungueltige Zeile so endet, dass die naechste an +/*N*/ // der 'gleichen' Textstelle wie vorher beginnt, also nicht +/*N*/ // anders umgebrochen wird, brauche ich dort auch nicht die +/*N*/ // textbreiten neu bestimmen: +/*N*/ if ( nEnd == ( aSaveLine.GetEnd() + nInvalidDiff ) ) +/*N*/ { +/*N*/ bCalcCharPositions = sal_False; +/*N*/ bLineBreak = sal_False; +/*N*/ pParaPortion->CorrectValuesBehindLastFormattedLine( nLine ); +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( !bSameLineAgain ) +/*N*/ { +/*N*/ nIndex = pLine->GetEnd(); // naechste Zeile Start = letzte Zeile Ende +/*N*/ // weil nEnd hinter das letzte Zeichen zeigt! +/*N*/ +/*N*/ sal_uInt16 nEndPortion = pLine->GetEndPortion(); +/*N*/ +/*N*/ // Naechste Zeile oder ggf. neue Zeile.... +/*N*/ pLine = 0; +/*N*/ if ( nLine < pParaPortion->GetLines().Count()-1 ) +/*N*/ pLine = pParaPortion->GetLines().GetObject( ++nLine ); +/*N*/ if ( pLine && ( nIndex >= pNode->Len() ) ) +/*N*/ { +/*N*/ nDelFromLine = nLine; +/*N*/ break; +/*N*/ } +/*N*/ if ( !pLine ) +/*N*/ { +/*N*/ if ( nIndex < pNode->Len() ) +/*N*/ { +/*N*/ pLine = new EditLine; +/*N*/ pParaPortion->GetLines().Insert( pLine, ++nLine ); +/*N*/ } +/*N*/ else if ( nIndex && bLineBreak && GetTextRanger() ) +/*N*/ { +/*?*/ // normaly CreateAndInsertEmptyLine would be called, but I want to use +/*?*/ // CreateLines, so I need Polygon code only here... +/*?*/ TextPortion* pDummyPortion = new TextPortion( 0 ); +/*?*/ pParaPortion->GetTextPortions().Insert( pDummyPortion, pParaPortion->GetTextPortions().Count() ); +/*?*/ pLine = new EditLine; +/*?*/ pParaPortion->GetLines().Insert( pLine, ++nLine ); +/*?*/ bForceOneRun = TRUE; +/*?*/ bProcessingEmptyLine = TRUE; +/*N*/ } +/*N*/ } +/*N*/ if ( pLine ) +/*N*/ { +/*N*/ aSaveLine = *pLine; +/*N*/ pLine->SetStart( nIndex ); +/*N*/ pLine->SetEnd( nIndex ); +/*N*/ pLine->SetStartPortion( nEndPortion+1 ); +/*N*/ pLine->SetEndPortion( nEndPortion+1 ); +/*N*/ } +/*N*/ } +/*N*/ } // while ( Index < Len ) +/*N*/ +/*N*/ if ( nDelFromLine != 0xFFFF ) +/*N*/ pParaPortion->GetLines().DeleteFromLine( nDelFromLine ); +/*N*/ +/*N*/ DBG_ASSERT( pParaPortion->GetLines().Count(), "Keine Zeile nach CreateLines!" ); +/*N*/ +/*N*/ if ( bLineBreak == sal_True ) +/*N*/ CreateAndInsertEmptyLine( pParaPortion, nStartPosY ); +/*N*/ +/*N*/ delete[] pBuf; +/*N*/ +/*N*/ sal_Bool bHeightChanged = FinishCreateLines( pParaPortion ); +/*N*/ +/*N*/ if ( bMapChanged ) +/*?*/ GetRefDevice()->Pop(); +/*N*/ +/*N*/ GetRefDevice()->SetLayoutMode( nOldLayoutMode ); +/*N*/ +/*N*/ return bHeightChanged; +/*N*/ } + +/*N*/ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion, sal_uInt32 nStartPosY ) +/*N*/ { +/*N*/ DBG_ASSERT( !GetTextRanger(), "Don't use CreateAndInsertEmptyLine with a polygon!" ); +/*N*/ +/*N*/ EditLine* pTmpLine = new EditLine; +/*N*/ pTmpLine->SetStart( pParaPortion->GetNode()->Len() ); +/*N*/ pTmpLine->SetEnd( pParaPortion->GetNode()->Len() ); +/*N*/ pParaPortion->GetLines().Insert( pTmpLine, pParaPortion->GetLines().Count() ); +/*N*/ +/*N*/ sal_Bool bLineBreak = pParaPortion->GetNode()->Len() ? sal_True : sal_False; +/*N*/ const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pParaPortion->GetNode() ); +/*N*/ const SvxLineSpacingItem& rLSItem = (const SvxLineSpacingItem&)pParaPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL ); +/*N*/ short nStartX = GetXValue( (short)(rLRItem.GetTxtLeft() + rLRItem.GetTxtFirstLineOfst()) ); +/*N*/ +/*N*/ Rectangle aBulletArea = Rectangle( Point(), Point() ); +/*N*/ if ( bLineBreak == sal_True ) +/*N*/ { +/*N*/ nStartX = (short)GetXValue( rLRItem.GetTxtLeft() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aBulletArea = GetEditEnginePtr()->GetBulletArea( GetParaPortions().GetPos( pParaPortion ) ); +/*N*/ if ( aBulletArea.Right() > 0 ) +/*?*/ pParaPortion->SetBulletX( (sal_uInt16) GetXValue( aBulletArea.Right() ) ); +/*N*/ else +/*N*/ pParaPortion->SetBulletX( 0 ); // Falls Bullet falsch eingestellt. +/*N*/ if ( pParaPortion->GetBulletX() > nStartX ) +/*N*/ { +/*?*/ nStartX = (short)GetXValue( rLRItem.GetTxtLeft() ); +/*?*/ if ( pParaPortion->GetBulletX() > nStartX ) +/*?*/ nStartX = pParaPortion->GetBulletX(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ SvxFont aTmpFont; +/*N*/ SeekCursor( pParaPortion->GetNode(), bLineBreak ? pParaPortion->GetNode()->Len() : 0, aTmpFont ); +/*N*/ aTmpFont.SetPhysFont( pRefDev ); +/*N*/ +/*N*/ TextPortion* pDummyPortion = new TextPortion( 0 ); +/*N*/ pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev, String() ); +/*N*/ pParaPortion->GetTextPortions().Insert( pDummyPortion, pParaPortion->GetTextPortions().Count() ); +/*N*/ FormatterFontMetric aFormatterMetrics; +/*N*/ RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont ); +/*N*/ pTmpLine->SetMaxAscent( aFormatterMetrics.nMaxAscent ); +/*N*/ pTmpLine->SetHeight( (sal_uInt16) pDummyPortion->GetSize().Height() ); +/*N*/ sal_uInt16 nLineHeight = aFormatterMetrics.GetHeight(); +/*N*/ if ( nLineHeight > pTmpLine->GetHeight() ) +/*N*/ pTmpLine->SetHeight( nLineHeight ); +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ USHORT nPara = GetParaPortions().GetPos( pParaPortion ); +/*N*/ SvxAdjust eJustification = GetJustification( nPara ); +/*N*/ long nMaxLineWidth = !IsVertical() ? aPaperSize.Width() : aPaperSize.Height(); +/*N*/ nMaxLineWidth -= GetXValue( rLRItem.GetRight() ); +/*N*/ long nTextXOffset = 0; +/*N*/ if ( nMaxLineWidth < 0 ) +/*N*/ nMaxLineWidth = 1; +/*N*/ if ( eJustification == SVX_ADJUST_CENTER ) +/*N*/ nStartX = nMaxLineWidth / 2; +/*N*/ else if ( eJustification == SVX_ADJUST_RIGHT ) +/*?*/ nStartX = (short)nMaxLineWidth; +/*N*/ +/*N*/ nStartX += (short)nTextXOffset; +/*N*/ } +/*N*/ +/*N*/ pTmpLine->SetStartPosX( nStartX ); +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ if ( rLSItem.GetLineSpaceRule() == SVX_LINE_SPACE_MIN ) +/*N*/ { +/*?*/ sal_uInt16 nMinHeight = rLSItem.GetLineHeight(); +/*?*/ sal_uInt16 nTxtHeight = pTmpLine->GetHeight(); +/*?*/ if ( nTxtHeight < nMinHeight ) +/*?*/ { +/*?*/ // Der Ascent muss um die Differenz angepasst werden: +/*?*/ long nDiff = nMinHeight - nTxtHeight; +/*?*/ pTmpLine->SetMaxAscent( (sal_uInt16)(pTmpLine->GetMaxAscent() + nDiff) ); +/*?*/ pTmpLine->SetHeight( nMinHeight, nTxtHeight ); +/*?*/ } +/*N*/ } +/*N*/ else if ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_PROP ) +/*N*/ { +/*?*/ USHORT nPara = GetParaPortions().GetPos( pParaPortion ); +/*?*/ if ( nPara || ( pTmpLine->GetStartPortion() != 0 ) ) // Nicht die aller erste Zeile +/*?*/ { +/*?*/ // #100508# There are documents with PropLineSpace 0, why? +/*?*/ if ( rLSItem.GetPropLineSpace() && ( rLSItem.GetPropLineSpace() != 100 ) ) +/*?*/ { +/*?*/ sal_uInt16 nTxtHeight = pTmpLine->GetHeight(); +/*?*/ sal_uInt32 nH = nTxtHeight; +/*?*/ nH *= rLSItem.GetPropLineSpace(); +/*?*/ nH /= 100; +/*?*/ // Der Ascent muss um die Differenz angepasst werden: +/*?*/ long nDiff = pTmpLine->GetHeight() - nH; +/*?*/ if ( nDiff > pTmpLine->GetMaxAscent() ) +/*?*/ nDiff = pTmpLine->GetMaxAscent(); +/*?*/ pTmpLine->SetMaxAscent( (sal_uInt16)(pTmpLine->GetMaxAscent() - nDiff) ); +/*?*/ pTmpLine->SetHeight( (sal_uInt16)nH, nTxtHeight ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( !bLineBreak ) +/*N*/ { +/*N*/ long nMinHeight = aBulletArea.GetHeight(); +/*N*/ if ( nMinHeight > (long)pTmpLine->GetHeight() ) +/*N*/ { +/*?*/ long nDiff = nMinHeight - (long)pTmpLine->GetHeight(); +/*?*/ // nDiff auf oben und unten verteilen. +/*?*/ pTmpLine->SetMaxAscent( (sal_uInt16)(pTmpLine->GetMaxAscent() + nDiff/2) ); +/*?*/ pTmpLine->SetHeight( (sal_uInt16)nMinHeight ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // -2: Die neue ist bereits eingefuegt. +/*N*/ EditLine* pLastLine = pParaPortion->GetLines().GetObject( pParaPortion->GetLines().Count()-2 ); +/*N*/ DBG_ASSERT( pLastLine, "Weicher Umbruch, keine Zeile ?!" ); +/*N*/ DBG_ASSERT( pLastLine->GetEnd() == pParaPortion->GetNode()->Len(), "Doch anders?" ); +/*N*/ // pTmpLine->SetStart( pLastLine->GetEnd() ); +/*N*/ // pTmpLine->SetEnd( pLastLine->GetEnd() ); +/*N*/ sal_uInt16 nPos = (sal_uInt16) pParaPortion->GetTextPortions().Count() - 1 ; +/*N*/ pTmpLine->SetStartPortion( nPos ); +/*N*/ pTmpLine->SetEndPortion( nPos ); +/*N*/ } +/*N*/ } + +/*N*/ sal_Bool ImpEditEngine::FinishCreateLines( ParaPortion* pParaPortion ) +/*N*/ { +/*N*/ // CalcCharPositions( pParaPortion ); +/*N*/ pParaPortion->SetValid(); +/*N*/ long nOldHeight = pParaPortion->GetHeight(); +/*N*/ // sal_uInt16 nPos = GetParaPortions().GetPos( pParaPortion ); +/*N*/ // DBG_ASSERT( nPos != USHRT_MAX, "FinishCreateLines: Portion nicht in Liste!" ); +/*N*/ // ParaPortion* pPrev = nPos ? GetParaPortions().GetObject( nPos-1 ) : 0; +/*N*/ CalcHeight( pParaPortion ); +/*N*/ +/*N*/ DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "FinishCreateLines: Keine Text-Portion?" ); +/*N*/ sal_Bool bRet = ( pParaPortion->GetHeight() != nOldHeight ); +/*N*/ return bRet; +/*N*/ } + +/*N*/ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, TextPortion* pPortion, sal_uInt16 nPortionStart, long nRemainingWidth, sal_Bool bCanHyphenate ) +/*N*/ { +/*N*/ ContentNode* const pNode = pParaPortion->GetNode(); +/*N*/ +/*N*/ sal_uInt16 nBreakInLine = nPortionStart - pLine->GetStart(); +/*N*/ sal_uInt16 nMax = nBreakInLine + pPortion->GetLen(); +/*N*/ while ( ( nBreakInLine < nMax ) && ( pLine->GetCharPosArray()[nBreakInLine] < nRemainingWidth ) ) +/*N*/ nBreakInLine++; +/*N*/ +/*N*/ sal_uInt16 nMaxBreakPos = nBreakInLine + pLine->GetStart(); +/*N*/ sal_uInt16 nBreakPos = 0xFFFF; +/*N*/ +/*N*/ sal_Bool bCompressBlank = sal_False; +/*N*/ sal_Bool bHyphenated = sal_False; +/*N*/ sal_Bool bHangingPunctuation = sal_False; +/*N*/ sal_Unicode cAlternateReplChar = 0; +/*N*/ sal_Unicode cAlternateExtraChar = 0; +/*N*/ +/*N*/ if ( ( nMaxBreakPos < ( nMax + pLine->GetStart() ) ) && ( pNode->GetChar( nMaxBreakPos ) == ' ' ) ) +/*N*/ { +/*N*/ // Break behind the blank, blank will be compressed... +/*N*/ nBreakPos = nMaxBreakPos + 1; +/*N*/ bCompressBlank = sal_True; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ sal_uInt16 nMinBreakPos = pLine->GetStart(); +/*N*/ USHORT nAttrs = pNode->GetCharAttribs().GetAttribs().Count(); +/*N*/ for ( USHORT nAttr = nAttrs; nAttr; ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = pNode->GetCharAttribs().GetAttribs()[--nAttr]; +/*N*/ if ( pAttr->IsFeature() && ( pAttr->GetEnd() > nMinBreakPos ) && ( pAttr->GetEnd() <= nMaxBreakPos ) ) +/*N*/ { +/*N*/ nMinBreakPos = pAttr->GetEnd(); +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ lang::Locale aLocale = GetLocale( EditPaM( pNode, nMaxBreakPos ) ); +/*N*/ +/*N*/ Reference < i18n::XBreakIterator > xBI = ImplGetBreakIterator(); +/*N*/ OUString aText( *pNode ); +/*N*/ Reference< XHyphenator > xHyph; +/*N*/ i18n::LineBreakHyphenationOptions aHyphOptions( xHyph, Sequence< PropertyValue >(), 1 ); +/*N*/ i18n::LineBreakUserOptions aUserOptions; +/*N*/ +/*N*/ const i18n::ForbiddenCharacters* pForbidden = GetForbiddenCharsTable()->GetForbiddenCharacters( SvxLocaleToLanguage( aLocale ), TRUE ); +/*N*/ aUserOptions.forbiddenBeginCharacters = pForbidden->beginLine; +/*N*/ aUserOptions.forbiddenEndCharacters = pForbidden->endLine; +/*N*/ aUserOptions.applyForbiddenRules = ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_FORBIDDENRULES )).GetValue(); +/*N*/ aUserOptions.allowPunctuationOutsideMargin = ((const SfxBoolItem&)pNode->GetContentAttribs().GetItem( EE_PARA_HANGINGPUNCTUATION )).GetValue(); +/*N*/ aUserOptions.allowHyphenateEnglish = FALSE; +/*N*/ +/*N*/ i18n::LineBreakResults aLBR = xBI->getLineBreak( *pNode, nMaxBreakPos, aLocale, nMinBreakPos, aHyphOptions, aUserOptions ); +/*N*/ nBreakPos = (USHORT)aLBR.breakIndex; +/*N*/ +/*N*/ // BUG in I18N - under special condition (break behind field, #87327#) breakIndex is < nMinBreakPos +/*N*/ if ( nBreakPos < nMinBreakPos ) +/*N*/ { +/*N*/ nBreakPos = nMinBreakPos; +/*N*/ } +/*N*/ else if ( ( nBreakPos > nMaxBreakPos ) && !aUserOptions.allowPunctuationOutsideMargin ) +/*N*/ { +/*N*/ DBG_ERROR( "I18N: XBreakIterator::getLineBreak returns position > Max" ); +/*N*/ nBreakPos = nMaxBreakPos; +/*N*/ } +/*N*/ +/*N*/ // #101795# nBreakPos can never be outside the portion, even not with hangig punctuation +/*N*/ if ( nBreakPos > nMaxBreakPos ) +/*N*/ nBreakPos = nMaxBreakPos; +/*N*/ +/*N*/ // BUG in I18N - the japanese dot is in the next line! +/*N*/ // !!! Testen!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ if ( (nBreakPos + ( aUserOptions.allowPunctuationOutsideMargin ? 0 : 1 ) ) <= nMaxBreakPos ) +/*N*/ { +/*N*/ sal_Unicode cFirstInNextLine = ( (nBreakPos+1) < pNode->Len() ) ? pNode->GetChar( nBreakPos ) : 0; +/*N*/ if ( cFirstInNextLine == 12290 ) +/*N*/ nBreakPos++; +/*N*/ } +/*N*/ +/*N*/ bHangingPunctuation = ( nBreakPos > nMaxBreakPos ) ? sal_True : sal_False; +/*N*/ pLine->SetHangingPunctuation( bHangingPunctuation ); +/*N*/ +/*N*/ if ( nBreakPos <= pLine->GetStart() ) +/*N*/ { +/*N*/ // keine Trenner in Zeile => abhacken ! +/*N*/ nBreakPos = nMaxBreakPos; +/*N*/ // MT: I18N nextCharacters !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +/*N*/ if ( nBreakPos <= pLine->GetStart() ) +/*N*/ nBreakPos = pLine->GetStart() + 1; // Sonst Endlosschleife! +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // die angeknackste Portion ist die End-Portion +/*N*/ pLine->SetEnd( nBreakPos ); +/*N*/ +/*N*/ sal_uInt16 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, pLine ); +/*N*/ +/*N*/ if ( !bCompressBlank && !bHangingPunctuation ) +/*N*/ { +/*N*/ // #96187# When justification is not SVX_ADJUST_LEFT, it's important to compress +/*N*/ // the trailing space even if there is enough room for the space... +/*N*/ // Don't check for SVX_ADJUST_LEFT, doesn't matter to compress in this case too... +/*N*/ DBG_ASSERT( nBreakPos > pLine->GetStart(), "ImpBreakLines - BreakPos not expected!" ); +/*N*/ if ( pNode->GetChar( nBreakPos-1 ) == ' ' ) +/*N*/ bCompressBlank = sal_True; +/*N*/ } +/*N*/ +/*N*/ if ( bCompressBlank || bHangingPunctuation ) +/*N*/ { +/*N*/ TextPortion* pTP = pParaPortion->GetTextPortions().GetObject( nEndPortion ); +/*N*/ DBG_ASSERT( pTP->GetKind() == PORTIONKIND_TEXT, "BlankRubber: Keine TextPortion!" ); +/*N*/ DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion am Anfang der Zeile?" ); +/*N*/ sal_uInt16 nPosInArray = nBreakPos - 1 - pLine->GetStart(); +/*N*/ pTP->GetSize().Width() = ( nPosInArray && ( pTP->GetLen() > 1 ) ) ? pLine->GetCharPosArray()[ nPosInArray-1 ] : 0; +/*N*/ pLine->GetCharPosArray()[ nPosInArray ] = pTP->GetSize().Width(); +/*N*/ } +/*N*/ else if ( bHyphenated ) +/*N*/ { +/*N*/ // Eine Portion fuer den Trenner einbauen... +/*N*/ TextPortion* pHyphPortion = new TextPortion( 0 ); +/*N*/ pHyphPortion->GetKind() = PORTIONKIND_HYPHENATOR; +/*N*/ String aHyphText( CH_HYPH ); +/*N*/ if ( cAlternateReplChar ) +/*N*/ { +/*?*/ TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nEndPortion ); +/*?*/ DBG_ASSERT( pPrev && pPrev->GetLen(), "Hyphenate: Prev portion?!" ); +/*?*/ pPrev->SetLen( pPrev->GetLen() - 1 ); +/*?*/ pHyphPortion->SetLen( 1 ); +/*?*/ pHyphPortion->SetExtraValue( cAlternateReplChar ); +/*?*/ // Breite der Portion davor korrigieren: +/*?*/ pPrev->GetSize().Width() = +/*?*/ pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() - 1 ]; +/*N*/ } +/*N*/ else if ( cAlternateExtraChar ) +/*N*/ { +/*?*/ pHyphPortion->SetExtraValue( cAlternateExtraChar ); +/*?*/ aHyphText.Insert( cAlternateExtraChar, 0 ); +/*N*/ } +/*N*/ +/*N*/ // Breite der Hyph-Portion ermitteln: +/*N*/ SvxFont aFont; +/*N*/ SeekCursor( pParaPortion->GetNode(), nBreakPos, aFont ); +/*N*/ aFont.SetPhysFont( GetRefDevice() ); +/*N*/ pHyphPortion->GetSize().Height() = GetRefDevice()->GetTextHeight(); +/*N*/ pHyphPortion->GetSize().Width() = GetRefDevice()->GetTextWidth( aHyphText ); +/*N*/ +/*N*/ pParaPortion->GetTextPortions().Insert( pHyphPortion, ++nEndPortion ); +/*N*/ } +/*N*/ pLine->SetEndPortion( nEndPortion ); +/*N*/ } + +/*N*/ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine* pLine, long nRemainingSpace ) +/*N*/ { +/*N*/ DBG_ASSERT( nRemainingSpace > 0, "AdjustBlocks: Etwas zuwenig..." ); +/*N*/ DBG_ASSERT( pLine, "AdjustBlocks: Zeile ?!" ); +/*N*/ if ( ( nRemainingSpace < 0 ) || pLine->IsEmpty() ) +/*N*/ return ; +/*N*/ +/*N*/ const USHORT nFirstChar = pLine->GetStart(); +/*N*/ const USHORT nLastChar = pLine->GetEnd() -1; // Last zeigt dahinter +/*N*/ ContentNode* pNode = pParaPortion->GetNode(); +/*N*/ +/*N*/ DBG_ASSERT( nLastChar < pNode->Len(), "AdjustBlocks: Out of range!" ); +/*N*/ +/*N*/ // Search blanks or Kashidas... +/*N*/ SvUShorts aPositions; +/*N*/ USHORT nChar; +/*N*/ for ( nChar = nFirstChar; nChar <= nLastChar; nChar++ ) +/*N*/ { +/*N*/ if ( pNode->GetChar(nChar) == ' ' ) +/*N*/ { +/*N*/ // Don't use blank if language is arabic +/*N*/ LanguageType eLang = GetLanguage( EditPaM( pNode, nChar ) ); +/*N*/ if ( MsLangId::getPrimaryLanguage( eLang) != LANGUAGE_ARABIC_PRIMARY_ONLY ) +/*N*/ aPositions.Insert( nChar, aPositions.Count() ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Kashidas ? +/*N*/ ImpFindKashidas( pNode, nFirstChar, nLastChar, aPositions ); +/*N*/ +/*N*/ +/*N*/ if ( !aPositions.Count() ) +/*N*/ return; +/*N*/ +/*N*/ // Wenn das letzte Zeichen ein Blank ist, will ich es nicht haben! +/*N*/ // Die Breite muss auf die Blocker davor verteilt werden... +/*N*/ // Aber nicht, wenn es das einzige ist +/*N*/ if ( ( pNode->GetChar( nLastChar ) == ' ' ) && ( aPositions.Count() > 1 ) && ( MsLangId::getPrimaryLanguage( GetLanguage( EditPaM( pNode, nLastChar ) ) ) != LANGUAGE_ARABIC_PRIMARY_ONLY ) ) +/*N*/ { +/*N*/ aPositions.Remove( aPositions.Count()-1, 1 ); +/*N*/ USHORT nPortionStart, nPortion; +/*N*/ nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart ); +/*N*/ TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ]; +/*N*/ long nRealWidth = pLine->GetCharPosArray()[nLastChar-nFirstChar]; +/*N*/ long nBlankWidth = nRealWidth; +/*N*/ if ( nLastChar > nPortionStart ) +/*N*/ nBlankWidth -= pLine->GetCharPosArray()[nLastChar-nFirstChar-1]; +/*N*/ // Evtl. ist das Blank schon in ImpBreakLine abgezogen worden: +/*N*/ if ( nRealWidth == pLastPortion->GetSize().Width() ) +/*N*/ { +/*N*/ // Beim letzten Zeichen muss die Portion hinter dem Blank aufhoeren +/*N*/ // => Korrektur vereinfachen: +/*N*/ DBG_ASSERT( ( nPortionStart + pLastPortion->GetLen() ) == ( nLastChar+1 ), "Blank doch nicht am Portion-Ende?!" ); +/*N*/ pLastPortion->GetSize().Width() -= nBlankWidth; +/*N*/ nRemainingSpace += nBlankWidth; +/*N*/ } +/*N*/ pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth; +/*N*/ } +/*N*/ +/*N*/ USHORT nGaps = aPositions.Count(); +/*N*/ const long nMore4Everyone = nRemainingSpace / nGaps; +/*N*/ long nSomeExtraSpace = nRemainingSpace - nMore4Everyone*nGaps; +/*N*/ +/*N*/ DBG_ASSERT( nSomeExtraSpace < (long)nGaps, "AdjustBlocks: ExtraSpace zu gross" ); +/*N*/ DBG_ASSERT( nSomeExtraSpace >= 0, "AdjustBlocks: ExtraSpace < 0 " ); +/*N*/ +/*N*/ // Die Positionen im Array und die Portion-Breiten korrigieren: +/*N*/ // Letztes Zeichen wird schon nicht mehr beachtet... +/*N*/ for ( USHORT n = 0; n < aPositions.Count(); n++ ) +/*N*/ { +/*N*/ nChar = aPositions[n]; +/*N*/ if ( nChar < nLastChar ) +/*N*/ { +/*N*/ USHORT nPortionStart, nPortion; +/*N*/ nPortion = pParaPortion->GetTextPortions().FindPortion( nChar, nPortionStart ); +/*N*/ TextPortion* pLastPortion = pParaPortion->GetTextPortions()[ nPortion ]; +/*N*/ +/*N*/ // Die Breite der Portion: +/*N*/ pLastPortion->GetSize().Width() += nMore4Everyone; +/*N*/ if ( nSomeExtraSpace ) +/*N*/ pLastPortion->GetSize().Width()++; +/*N*/ +/*N*/ // Correct positions in array +/*N*/ // Even for kashidas just change positions, VCL will then draw the kashida automaticly +/*N*/ USHORT nPortionEnd = nPortionStart + pLastPortion->GetLen(); +/*N*/ for ( USHORT n = nChar; n < nPortionEnd; n++ ) +/*N*/ { +/*N*/ pLine->GetCharPosArray()[n-nFirstChar] += nMore4Everyone; +/*N*/ if ( nSomeExtraSpace ) +/*N*/ pLine->GetCharPosArray()[n-nFirstChar]++; +/*N*/ } +/*N*/ +/*N*/ if ( nSomeExtraSpace ) +/*N*/ nSomeExtraSpace--; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Now the text width contains the extra width... +/*N*/ pLine->SetTextWidth( pLine->GetTextWidth() + nRemainingSpace ); +/*N*/ } + +/*N*/ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, USHORT nStart, USHORT nEnd, SvUShorts& rArray ) +/*N*/ { +/*N*/ // the search has to be performed on a per word base +/*N*/ +/*N*/ EditSelection aWordSel( EditPaM( pNode, nStart ) ); +/*N*/ aWordSel = SelectWord( aWordSel, ::com::sun::star::i18n::WordType::DICTIONARY_WORD ); +/*N*/ if ( aWordSel.Min().GetIndex() < nStart ) +/*N*/ aWordSel.Min().GetIndex() = nStart; +/*N*/ +/*N*/ while ( ( aWordSel.Min().GetNode() == pNode ) && ( aWordSel.Min().GetIndex() < nEnd ) ) +/*N*/ { +/*N*/ if ( aWordSel.Max().GetIndex() > nEnd ) +/*N*/ aWordSel.Max().GetIndex() = nEnd; +/*N*/ +/*N*/ String aWord = GetSelected( aWordSel ); +/*N*/ xub_StrLen nIdx = 0; +/*N*/ xub_StrLen nKashidaPos = STRING_LEN; +/*N*/ xub_Unicode cCh; +/*N*/ xub_Unicode cPrevCh = 0; +/*N*/ +/*N*/ while ( nIdx < aWord.Len() ) +/*N*/ { +/*N*/ cCh = aWord.GetChar( nIdx ); +/*N*/ +/*N*/ // 1. Priority: +/*N*/ // after user inserted kashida +/*N*/ if ( 0x640 == cCh ) +/*N*/ { +/*?*/ nKashidaPos = aWordSel.Min().GetIndex() + nIdx; +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ // 2. Priority: +/*N*/ // after a Seen or Sad +/*N*/ if ( nIdx + 1 < aWord.Len() && +/*N*/ ( 0x633 == cCh || 0x635 == cCh ) ) +/*N*/ { +/*?*/ nKashidaPos = aWordSel.Min().GetIndex() + nIdx; +/*?*/ break; +/*N*/ } +/*N*/ +/*N*/ // 3. Priority: +/*N*/ // before final form of Teh Marbuta, Hah, Dal +/*N*/ // 4. Priority: +/*N*/ // before final form of Alef, Lam or Kaf +/*N*/ if ( nIdx && nIdx + 1 == aWord.Len() && +/*N*/ ( 0x629 == cCh || 0x62D == cCh || 0x62F == cCh || +/*N*/ 0x627 == cCh || 0x644 == cCh || 0x643 == cCh ) ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 DBG_ASSERT( 0 != cPrevCh, "No previous character" ); +/*N*/ } +/*N*/ +/*N*/ // 5. Priority: +/*N*/ // before media Bah +/*N*/ if ( nIdx && nIdx + 1 < aWord.Len() && 0x628 == cCh ) +/*N*/ { +/*?*/ DBG_ASSERT( 0 != cPrevCh, "No previous character" ); +/*?*/ +/*?*/ // check if next character is Reh, Yeh or Alef Maksura +/*?*/ xub_Unicode cNextCh = aWord.GetChar( nIdx + 1 ); +/*?*/ +/*?*/ if ( 0x631 == cNextCh || 0x64A == cNextCh || +/*?*/ 0x649 == cNextCh ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 // check if character is connectable to previous character, +/*?*/ } +/*N*/ } +/*N*/ +/*N*/ // 6. Priority: +/*N*/ // other connecting possibilities +/*N*/ if ( nIdx && nIdx + 1 == aWord.Len() && +/*N*/ 0x60C <= cCh && 0x6FE >= cCh ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 DBG_ASSERT( 0 != cPrevCh, "No previous character" ); +/*N*/ } +/*N*/ +/*N*/ // Do not consider Fathatan, Dammatan, Kasratan, Fatha, +/*N*/ // Damma, Kasra, Shadda and Sukun when checking if +/*N*/ // a character can be connected to previous character. +/*N*/ if ( cCh < 0x64B || cCh > 0x652 ) +/*N*/ cPrevCh = cCh; +/*N*/ +/*N*/ ++nIdx; +/*N*/ } // end of current word +/*N*/ +/*N*/ if ( STRING_LEN != nKashidaPos ) +/*?*/ rArray.Insert( nKashidaPos, rArray.Count() ); +/*N*/ +/*N*/ aWordSel = WordRight( aWordSel.Max(), ::com::sun::star::i18n::WordType::DICTIONARY_WORD ); +/*N*/ aWordSel = SelectWord( aWordSel, ::com::sun::star::i18n::WordType::DICTIONARY_WORD ); +/*N*/ } +/*N*/ } + +/*N*/ sal_uInt16 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_uInt16 nPos, EditLine* pCurLine ) +/*N*/ { +/*N*/ DBG_ASSERT( pPortion, "SplitTextPortion: Welche ?" ); +/*N*/ +/*N*/ // Die Portion bei nPos wird geplittet, wenn bei nPos nicht +/*N*/ // sowieso ein Wechsel ist +/*N*/ if ( nPos == 0 ) +/*N*/ return 0; +/*N*/ +/*N*/ sal_uInt16 nSplitPortion; +/*N*/ sal_uInt16 nTmpPos = 0; +/*N*/ TextPortion* pTextPortion = 0; +/*N*/ sal_uInt16 nPortions = pPortion->GetTextPortions().Count(); +/*N*/ for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ ) +/*N*/ { +/*N*/ TextPortion* pTP = pPortion->GetTextPortions().GetObject(nSplitPortion); +/*N*/ nTmpPos += pTP->GetLen(); +/*N*/ if ( nTmpPos >= nPos ) +/*N*/ { +/*N*/ if ( nTmpPos == nPos ) // dann braucht nichts geteilt werden +/*N*/ { +/*N*/ // Skip Portions with ExtraSpace +/*N*/ // while ( ( (nSplitPortion+1) < nPortions ) && (pPortion->GetTextPortions().GetObject(nSplitPortion+1)->GetKind() == PORTIONKIND_EXTRASPACE ) ) +/*N*/ // nSplitPortion++; +/*N*/ +/*N*/ return nSplitPortion; +/*N*/ } +/*N*/ pTextPortion = pTP; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ DBG_ASSERT( pTextPortion, "Position ausserhalb des Bereichs!" ); +/*N*/ DBG_ASSERT( pTextPortion->GetKind() == PORTIONKIND_TEXT, "SplitTextPortion: Keine TextPortion!" ); +/*N*/ +/*N*/ sal_uInt16 nOverlapp = nTmpPos - nPos; +/*N*/ pTextPortion->GetLen() -= nOverlapp; +/*N*/ TextPortion* pNewPortion = new TextPortion( nOverlapp ); +/*N*/ pPortion->GetTextPortions().Insert( pNewPortion, nSplitPortion+1 ); +/*N*/ // Groessen setzen: +/*N*/ if ( pCurLine ) +/*N*/ { +/*N*/ // Kein neues GetTextSize, sondern Werte aus Array verwenden: +/*N*/ DBG_ASSERT( nPos > pCurLine->GetStart(), "SplitTextPortion am Anfang der Zeile?" ); +/*N*/ pTextPortion->GetSize().Width() = pCurLine->GetCharPosArray()[ nPos-pCurLine->GetStart()-1 ]; +/*N*/ +/*N*/ if ( pTextPortion->GetExtraInfos() && pTextPortion->GetExtraInfos()->bCompressed ) +/*N*/ { +/*?*/ // We need the original size from the portion +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 USHORT nTxtPortionStart = pPortion->GetTextPortions().GetStartPos( nSplitPortion ); +/*N*/ } +/*N*/ } +/*N*/ else +/*?*/ pTextPortion->GetSize().Width() = (-1); +/*N*/ +/*N*/ return nSplitPortion; +/*N*/ } + +/*N*/ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_uInt16& rStart /* , sal_Bool bCreateBlockPortions */ ) +/*N*/ { +/*N*/ sal_uInt16 nStartPos = rStart; +/*N*/ ContentNode* pNode = pParaPortion->GetNode(); +/*N*/ DBG_ASSERT( pNode->Len(), "CreateTextPortions sollte nicht fuer leere Absaetze verwendet werden!" ); +/*N*/ +/*N*/ SortedPositions aPositions; +/*N*/ aPositions.Insert( (sal_uInt32) 0 ); +/*N*/ +/*N*/ sal_uInt16 nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttrib ) +/*N*/ { +/*N*/ // Start und Ende in das Array eintragen... +/*N*/ // Die InsertMethode laesst keine doppelten Werte zu.... +/*N*/ aPositions.Insert( pAttrib->GetStart() ); +/*N*/ aPositions.Insert( pAttrib->GetEnd() ); +/*N*/ nAttr++; +/*N*/ pAttrib = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ aPositions.Insert( pNode->Len() ); +/*N*/ +/*N*/ if ( !pParaPortion->aScriptInfos.Count() ) +/*?*/ ((ImpEditEngine*)this)->InitScriptTypes( GetParaPortions().GetPos( pParaPortion ) ); +/*N*/ +/*N*/ const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos; +/*N*/ for ( USHORT nT = 0; nT < rTypes.Count(); nT++ ) +/*N*/ aPositions.Insert( rTypes[nT].nStartPos ); +/*N*/ +/*N*/ const WritingDirectionInfos& rWritingDirections = pParaPortion->aWritingDirectionInfos; +/*N*/ for ( USHORT nD = 0; nD < rWritingDirections.Count(); nD++ ) +/*?*/ aPositions.Insert( rWritingDirections[nD].nStartPos ); +/*N*/ +/*N*/ if ( mpIMEInfos && mpIMEInfos->nLen && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetNode() == pNode ) ) +/*N*/ { +/*?*/ sal_uInt16 nLastAttr = 0xFFFF; +/*?*/ for( sal_uInt16 n = 0; n < mpIMEInfos->nLen; n++ ) +/*?*/ { +/*?*/ if ( mpIMEInfos->pAttribs[n] != nLastAttr ) +/*?*/ { +/*?*/ aPositions.Insert( mpIMEInfos->aPos.GetIndex() + n ); +/*?*/ nLastAttr = mpIMEInfos->pAttribs[n]; +/*?*/ } +/*?*/ } +/*?*/ aPositions.Insert( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ); +/*N*/ } +/*N*/ +/*N*/ // Ab ... loeschen: +/*N*/ // Leider muss die Anzahl der TextPortions mit aPositions.Count() +/*N*/ // nicht uebereinstimmen, da evtl. Zeilenumbrueche... +/*N*/ sal_uInt16 nPortionStart = 0; +/*N*/ sal_uInt16 nInvPortion = 0; +/*N*/ sal_uInt16 nP; for ( nP = 0; nP < pParaPortion->GetTextPortions().Count(); nP++ ) +/*N*/ { +/*N*/ TextPortion* pTmpPortion = pParaPortion->GetTextPortions().GetObject(nP); +/*N*/ nPortionStart += pTmpPortion->GetLen(); +/*N*/ if ( nPortionStart >= nStartPos ) +/*N*/ { +/*N*/ nPortionStart -= pTmpPortion->GetLen(); +/*N*/ rStart = nPortionStart; +/*N*/ nInvPortion = nP; +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT( nP < pParaPortion->GetTextPortions().Count() || !pParaPortion->GetTextPortions().Count(), "Nichts zum loeschen: CreateTextPortions" ); +/*N*/ if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen() > nStartPos ) ) +/*N*/ { +/*?*/ // lieber eine davor... +/*?*/ // Aber nur wenn es mitten in der Portion war, sonst ist es evtl. +/*?*/ // die einzige in der Zeile davor ! +/*?*/ nInvPortion--; +/*?*/ nPortionStart -= pParaPortion->GetTextPortions().GetObject(nInvPortion)->GetLen(); +/*N*/ } +/*N*/ pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion ); +/*N*/ +/*N*/ // Eine Portion kann auch durch einen Zeilenumbruch entstanden sein: +/*N*/ aPositions.Insert( nPortionStart ); +/*N*/ +/*N*/ sal_uInt16 nInvPos; +/*N*/ sal_Bool bFound = aPositions.Seek_Entry( nPortionStart, &nInvPos ); +/*N*/ DBG_ASSERT( bFound && ( nInvPos < (aPositions.Count()-1) ), "InvPos ?!" ); +/*N*/ for ( sal_uInt16 i = nInvPos+1; i < aPositions.Count(); i++ ) +/*N*/ { +/*N*/ TextPortion* pNew = new TextPortion( (sal_uInt16)aPositions[i] - (sal_uInt16)aPositions[i-1] ); +/*N*/ pParaPortion->GetTextPortions().Insert( pNew, pParaPortion->GetTextPortions().Count()); +/*N*/ } +/*N*/ +/*N*/ DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "Keine Portions?!" ); +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( pParaPortion->DbgCheckTextPortions(), "Portions kaputt?" ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_uInt16 nStartPos, short nNewChars ) +/*N*/ { +/*N*/ DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "Keine Portions!" ); +/*N*/ DBG_ASSERT( nNewChars, "RecalcTextPortion mit Diff == 0" ); +/*N*/ +/*N*/ ContentNode* const pNode = pParaPortion->GetNode(); +/*N*/ if ( nNewChars > 0 ) +/*N*/ { +/*N*/ // Wenn an nStartPos ein Attribut beginnt/endet, faengt eine neue Portion +/*N*/ // an, ansonsten wird die Portion an nStartPos erweitert. +/*N*/ +/*N*/ if ( pNode->GetCharAttribs().HasBoundingAttrib( nStartPos ) || IsScriptChange( EditPaM( pNode, nStartPos ) ) ) +/*N*/ { +/*N*/ sal_uInt16 nNewPortionPos = 0; +/*N*/ if ( nStartPos ) +/*?*/ nNewPortionPos = SplitTextPortion( pParaPortion, nStartPos ) + 1; +/*N*/ +/*N*/ // Eine leere Portion kann hier stehen, wenn der Absatz leer war, +/*N*/ // oder eine Zeile durch einen harten Zeilenumbruch entstanden ist. +/*N*/ if ( ( nNewPortionPos < pParaPortion->GetTextPortions().Count() ) && +/*N*/ !pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() ) +/*N*/ { +/*N*/ DBG_ASSERT( pParaPortion->GetTextPortions()[nNewPortionPos]->GetKind() == PORTIONKIND_TEXT, "Leere Portion war keine TextPortion!" ); +/*N*/ pParaPortion->GetTextPortions()[nNewPortionPos]->GetLen() += nNewChars; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ TextPortion* pNewPortion = new TextPortion( nNewChars ); +/*N*/ pParaPortion->GetTextPortions().Insert( pNewPortion, nNewPortionPos ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ sal_uInt16 nPortionStart; +/*N*/ const sal_uInt16 nTP = pParaPortion->GetTextPortions(). +/*N*/ FindPortion( nStartPos, nPortionStart ); +/*N*/ TextPortion* const pTP = pParaPortion->GetTextPortions()[ nTP ]; +/*N*/ DBG_ASSERT( pTP, "RecalcTextPortion: Portion nicht gefunden" ); +/*N*/ pTP->GetLen() += nNewChars; +/*N*/ pTP->GetSize().Width() = (-1); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ // Portion schrumpfen oder ggf. entfernen. +/*?*/ // Vor Aufruf dieser Methode muss sichergestellt sein, dass +/*?*/ // keine Portions in dem geloeschten Bereich lagen! +/*?*/ +/*?*/ // Es darf keine reinragende oder im Bereich startende Portion geben, +/*?*/ // also muss nStartPos <= nPos <= nStartPos - nNewChars(neg.) sein +/*?*/ sal_uInt16 nPortion = 0; +/*?*/ sal_uInt16 nPos = 0; +/*?*/ sal_uInt16 nEnd = nStartPos-nNewChars; +/*?*/ sal_uInt16 nPortions = pParaPortion->GetTextPortions().Count(); +/*?*/ TextPortion* pTP = 0; +/*?*/ for ( nPortion = 0; nPortion < nPortions; nPortion++ ) +/*?*/ { +/*?*/ pTP = pParaPortion->GetTextPortions()[ nPortion ]; +/*?*/ if ( ( nPos+pTP->GetLen() ) > nStartPos ) +/*?*/ { +/*?*/ DBG_ASSERT( nPos <= nStartPos, "Start falsch!" ); +/*?*/ DBG_ASSERT( nPos+pTP->GetLen() >= nEnd, "End falsch!" ); +/*?*/ break; +/*?*/ } +/*?*/ nPos += pTP->GetLen(); +/*?*/ } +/*?*/ DBG_ASSERT( pTP, "RecalcTextPortion: Portion nicht gefunden" ); +/*?*/ if ( ( nPos == nStartPos ) && ( (nPos+pTP->GetLen()) == nEnd ) ) +/*?*/ { +/*?*/ // Portion entfernen; +/*?*/ BYTE nType = pTP->GetKind(); +/*?*/ pParaPortion->GetTextPortions().Remove( nPortion ); +/*?*/ delete pTP; +/*?*/ if ( nType == PORTIONKIND_LINEBREAK ) +/*?*/ { +/*?*/ TextPortion* pNext = pParaPortion->GetTextPortions()[ nPortion ]; +/*?*/ if ( pNext && !pNext->GetLen() ) +/*?*/ { +/*?*/ // Dummy-Portion entfernen +/*?*/ pParaPortion->GetTextPortions().Remove( nPortion ); +/*?*/ delete pNext; +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ DBG_ASSERT( pTP->GetLen() > (-nNewChars), "Portion zu klein zum schrumpfen!" ); +/*?*/ pTP->GetLen() += nNewChars; +/*?*/ } +/*?*/ +/*?*/ // ganz am Schluss darf keine HYPHENATOR-Portion stehen bleiben... +/*?*/ DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "RecalcTextPortions: Keine mehr da!" ); +/*?*/ sal_uInt16 nLastPortion = pParaPortion->GetTextPortions().Count() - 1; +/*?*/ pTP = pParaPortion->GetTextPortions().GetObject( nLastPortion ); +/*?*/ if ( pTP->GetKind() == PORTIONKIND_HYPHENATOR ) +/*?*/ { +/*?*/ // Portion wegschmeissen, ggf. die davor korrigieren, wenn +/*?*/ // die Hyph-Portion ein Zeichen geschluckt hat... +/*?*/ pParaPortion->GetTextPortions().Remove( nLastPortion ); +/*?*/ if ( nLastPortion && pTP->GetLen() ) +/*?*/ { +/*?*/ TextPortion* pPrev = pParaPortion->GetTextPortions().GetObject( nLastPortion - 1 ); +/*?*/ DBG_ASSERT( pPrev->GetKind() == PORTIONKIND_TEXT, "Portion?!" ); +/*?*/ pPrev->SetLen( pPrev->GetLen() + pTP->GetLen() ); +/*?*/ pPrev->GetSize().Width() = (-1); +/*?*/ } +/*?*/ delete pTP; +/*?*/ } +/*N*/ } +/*N*/ #ifdef EDITDEBUG +/*N*/ DBG_ASSERT( pParaPortion->DbgCheckTextPortions(), "Portions kaputt?" ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::SetTextRanger( TextRanger* pRanger ) +/*N*/ { +/*N*/ if ( pTextRanger != pRanger ) +/*N*/ { +/*?*/ delete pTextRanger; +/*?*/ pTextRanger = pRanger; +/*?*/ +/*?*/ for ( sal_uInt16 nPara = 0; nPara < GetParaPortions().Count(); nPara++ ) +/*?*/ { +/*?*/ ParaPortion* pParaPortion = GetParaPortions().GetObject( nPara ); +/*?*/ pParaPortion->MarkSelectionInvalid( 0, pParaPortion->GetNode()->Len() ); +/*?*/ pParaPortion->GetLines().Reset(); +/*?*/ } +/*?*/ +/*?*/ FormatFullDoc(); +/*?*/ UpdateViews( GetActiveView() ); +/*?*/ if ( GetUpdateMode() && GetActiveView() ) +/*?*/ pActiveView->ShowCursor( sal_False, sal_False ); +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::SetVertical( BOOL bVertical ) +/*N*/ { +/*N*/ if ( IsVertical() != bVertical ) +/*N*/ { +/*?*/ GetEditDoc().SetVertical( bVertical ); +/*?*/ sal_Bool bUseCharAttribs = ( aStatus.GetControlWord() & EE_CNTRL_USECHARATTRIBS ) ? sal_True : sal_False; +/*?*/ GetEditDoc().CreateDefFont( bUseCharAttribs ); +/*?*/ if ( IsFormatted() ) +/*?*/ { +/*?*/ FormatFullDoc(); +/*?*/ UpdateViews( GetActiveView() ); +/*?*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rFont, OutputDevice* pOut, sal_uInt16 nIgnoreWhich ) +/*N*/ { +/*N*/ // Es war mal geplant, SeekCursor( nStartPos, nEndPos, ... ), damit nur +/*N*/ // ab der StartPosition neu gesucht wird. +/*N*/ // Problem: Es mussten zwei Listen beruecksichtigt/gefuehrt werden: +/*N*/ // OrderedByStart,OrderedByEnd. +/*N*/ +/*N*/ if ( nPos > pNode->Len() ) +/*N*/ nPos = pNode->Len(); +/*N*/ +/*N*/ rFont = pNode->GetCharAttribs().GetDefFont(); +/*N*/ +/*N*/ short nScriptType = GetScriptType( EditPaM( pNode, nPos ) ); +/*N*/ if ( ( nScriptType == i18n::ScriptType::ASIAN ) || ( nScriptType == i18n::ScriptType::COMPLEX ) ) +/*N*/ { +/*N*/ const SvxFontItem& rFontItem = (const SvxFontItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_FONTINFO, nScriptType ) ); +/*N*/ rFont.SetName( rFontItem.GetFamilyName() ); +/*N*/ rFont.SetFamily( rFontItem.GetFamily() ); +/*N*/ rFont.SetPitch( rFontItem.GetPitch() ); +/*N*/ rFont.SetCharSet( rFontItem.GetCharSet() ); +/*N*/ Size aSz( rFont.GetSize() ); +/*N*/ aSz.Height() = ((const SvxFontHeightItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_FONTHEIGHT, nScriptType ) ) ).GetHeight(); +/*N*/ rFont.SetSize( aSz ); +/*N*/ rFont.SetWeight( ((const SvxWeightItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_WEIGHT, nScriptType ))).GetWeight() ); +/*N*/ rFont.SetItalic( ((const SvxPostureItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_ITALIC, nScriptType ))).GetPosture() ); +/*N*/ rFont.SetLanguage( ((const SvxLanguageItem&)pNode->GetContentAttribs().GetItem( GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ))).GetLanguage() ); +/*N*/ } +/*N*/ +/*N*/ sal_uInt16 nRelWidth = ((const SvxCharScaleWidthItem&)pNode->GetContentAttribs().GetItem( EE_CHAR_FONTWIDTH)).GetValue(); +/*N*/ +/*N*/ if ( pOut ) +/*N*/ { +/*N*/ const SvxUnderlineItem& rTextLineColor = (const SvxUnderlineItem&)pNode->GetContentAttribs().GetItem( EE_CHAR_UNDERLINE ); +/*N*/ if ( rTextLineColor.GetColor() != COL_TRANSPARENT ) +/*?*/ pOut->SetTextLineColor( rTextLineColor.GetColor() ); +/*N*/ else +/*N*/ pOut->SetTextLineColor(); +/*N*/ } +/*N*/ +/*N*/ const SvxLanguageItem* pCJKLanguageItem = NULL; +/*N*/ +/*N*/ if ( aStatus.UseCharAttribs() ) +/*N*/ { +/*N*/ const CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ sal_uInt16 nAttr = 0; +/*N*/ EditCharAttrib* pAttrib = GetAttrib( rAttribs, nAttr ); +/*N*/ while ( pAttrib && ( pAttrib->GetStart() <= nPos ) ) +/*N*/ { +/*N*/ // Beim Seeken nicht die Attr beruecksichtigen, die dort beginnen! +/*N*/ // Leere Attribute werden beruecksichtigt( verwendet), da diese +/*N*/ // gerade eingestellt wurden. +/*N*/ // 12.4.95: Doch keine Leeren Attribute verwenden: +/*N*/ // - Wenn gerade eingestellt und leer => keine Auswirkung auf Font +/*N*/ // In einem leeren Absatz eingestellte Zeichen werden sofort wirksam. +/*N*/ if ( ( pAttrib->Which() != nIgnoreWhich ) && +/*N*/ ( ( ( pAttrib->GetStart() < nPos ) && ( pAttrib->GetEnd() >= nPos ) ) +/*N*/ || ( !pNode->Len() ) ) ) +/*N*/ { +/*N*/ DBG_ASSERT( ( pAttrib->Which() >= EE_CHAR_START ) && ( pAttrib->Which() <= EE_FEATURE_END ), "Unglueltiges Attribut in Seek() " ); +/*N*/ if ( IsScriptItemValid( pAttrib->Which(), nScriptType ) ) +/*N*/ { +/*N*/ pAttrib->SetFont( rFont, pOut ); +/*N*/ // #i1550# hard color attrib should win over text color from field +/*N*/ if ( pAttrib->Which() == EE_FEATURE_FIELD ) +/*N*/ { +/*N*/ EditCharAttrib* pColorAttr = pNode->GetCharAttribs().FindAttrib( EE_CHAR_COLOR, nPos ); +/*N*/ if ( pColorAttr ) +/*N*/ pColorAttr->SetFont( rFont, pOut ); +/*N*/ } +/*N*/ } +/*N*/ if ( pAttrib->Which() == EE_CHAR_FONTWIDTH ) +/*N*/ nRelWidth = ((const SvxCharScaleWidthItem*)pAttrib->GetItem())->GetValue(); +/*N*/ if ( pAttrib->Which() == EE_CHAR_LANGUAGE_CJK ) +/*N*/ pCJKLanguageItem = (const SvxLanguageItem*) pAttrib->GetItem(); +/*N*/ } +/*N*/ pAttrib = GetAttrib( rAttribs, ++nAttr ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( !pCJKLanguageItem ) +/*N*/ pCJKLanguageItem = (const SvxLanguageItem*) &pNode->GetContentAttribs().GetItem( EE_CHAR_LANGUAGE_CJK ); +/*N*/ +/*N*/ rFont.SetCJKContextLanguage( pCJKLanguageItem->GetLanguage() ); +/*N*/ +/*N*/ if ( rFont.GetKerning() && IsKernAsianPunctuation() && ( nScriptType == i18n::ScriptType::ASIAN ) ) +/*?*/ rFont.SetKerning( rFont.GetKerning() | KERNING_ASIAN ); +/*N*/ +/*N*/ if ( aStatus.DoNotUseColors() ) +/*N*/ { +/*?*/ // Hack fuer DL,weil JOE staendig die Pooldefaults verbiegt! +/*?*/ // const SvxColorItem& rColorItem = (const SvxColorItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_COLOR ); +/*?*/ rFont.SetColor( /* rColorItem.GetValue() */ COL_BLACK ); +/*N*/ } +/*N*/ +/*N*/ if ( aStatus.DoStretch() || ( nRelWidth != 100 ) ) +/*N*/ { +/*N*/ // Fuer das aktuelle Ausgabegeraet, weil es sonst bei einem +/*N*/ // Drucker als RefDev auf dem Bildschirm #?!@' aussieht! +/*N*/ OutputDevice* pDev = pOut ? pOut : GetRefDevice(); +/*N*/ rFont.SetPhysFont( pDev ); +/*N*/ FontMetric aMetric( pDev->GetFontMetric() ); +/*N*/ // Fuer die Hoehe nicht die Metriken nehmen, da das bei +/*N*/ // Hoch-/Tiefgestellt schief geht. +/*N*/ Size aRealSz( aMetric.GetSize().Width(), rFont.GetSize().Height() ); +/*N*/ if ( aStatus.DoStretch() ) +/*N*/ { +/*?*/ if ( nStretchY != 100 ) +/*?*/ { +/*?*/ aRealSz.Height() *= nStretchY; +/*?*/ aRealSz.Height() /= 100; +/*?*/ } +/*?*/ if ( nStretchX != 100 ) +/*?*/ { +/*?*/ aRealSz.Width() *= nStretchX; +/*?*/ aRealSz.Width() /= 100; +/*?*/ +/*?*/ // Auch das Kerning: (long wegen Zwischenergebnis) +/*?*/ long nKerning = rFont.GetFixKerning(); +/* + Die Ueberlegung war: Wenn neg. Kerning, aber StretchX = 200 + => Nicht das Kerning verdoppelt, also die Buchstaben weiter + zusammenziehen + --------------------------- + Kern StretchX =>Kern + --------------------------- + >0 <100 < (Proportional) + <0 <100 < (Proportional) + >0 >100 > (Proportional) + <0 >100 < (Der Betrag, also Antiprop) +*/ +/*?*/ if ( ( nKerning < 0 ) && ( nStretchX > 100 ) ) +/*?*/ { +/*?*/ // Antiproportional +/*?*/ nKerning *= 100; +/*?*/ nKerning /= nStretchX; +/*?*/ } +/*?*/ else if ( nKerning ) +/*?*/ { +/*?*/ // Proportional +/*?*/ nKerning *= nStretchX; +/*?*/ nKerning /= 100; +/*?*/ } +/*?*/ rFont.SetFixKerning( (short)nKerning ); +/*?*/ } +/*N*/ } +/*N*/ if ( nRelWidth != 100 ) +/*N*/ { +/*N*/ aRealSz.Width() *= nRelWidth; +/*N*/ aRealSz.Width() /= 100; +/*N*/ } +/*N*/ rFont.SetSize( aRealSz ); +/*N*/ // Font wird nicht restauriert... +/*N*/ } +/*N*/ +/*N*/ if ( ( ( rFont.GetColor() == COL_AUTO ) || ( IsForceAutoColor() ) ) && pOut ) +/*N*/ { +/*N*/ if ( IsAutoColorEnabled() && ( pOut->GetOutDevType() != OUTDEV_PRINTER ) ) +/*N*/ { +/*N*/ // Never use WindowTextColor on the printer +/*N*/ rFont.SetColor( GetAutoColor() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if ( ( GetBackgroundColor() != COL_AUTO ) && GetBackgroundColor().IsDark() ) +/*?*/ rFont.SetColor( COL_WHITE ); +/*?*/ else +/*?*/ rFont.SetColor( COL_BLACK ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( mpIMEInfos && mpIMEInfos->pAttribs && ( mpIMEInfos->aPos.GetNode() == pNode ) && +/*N*/ ( nPos > mpIMEInfos->aPos.GetIndex() ) && ( nPos <= ( mpIMEInfos->aPos.GetIndex() + mpIMEInfos->nLen ) ) ) +/*N*/ { +/*?*/ sal_uInt16 nAttr = mpIMEInfos->pAttribs[ nPos - mpIMEInfos->aPos.GetIndex() - 1 ]; +/*?*/ if ( nAttr & EXTTEXTINPUT_ATTR_UNDERLINE ) +/*?*/ rFont.SetUnderline( UNDERLINE_SINGLE ); +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_BOLDUNDERLINE ) +/*?*/ rFont.SetUnderline( UNDERLINE_BOLD ); +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_DOTTEDUNDERLINE ) +/*?*/ rFont.SetUnderline( UNDERLINE_DOTTED ); +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_DASHDOTUNDERLINE ) +/*?*/ rFont.SetUnderline( UNDERLINE_DOTTED ); +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_REDTEXT ) +/*?*/ rFont.SetColor( Color( COL_RED ) ); +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_HALFTONETEXT ) +/*?*/ rFont.SetColor( Color( COL_LIGHTGRAY ) ); +/*?*/ if ( nAttr & EXTTEXTINPUT_ATTR_HIGHLIGHT ) +/*?*/ { +/*?*/ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); +/*?*/ rFont.SetColor( rStyleSettings.GetHighlightTextColor() ); +/*?*/ rFont.SetFillColor( rStyleSettings.GetHighlightColor() ); +/*?*/ rFont.SetTransparent( FALSE ); +/*?*/ } +/*?*/ else if ( nAttr & EXTTEXTINPUT_ATTR_GRAYWAVELINE ) +/*?*/ { +/*?*/ rFont.SetUnderline( UNDERLINE_WAVE ); +/*?*/ if( pOut ) +/*?*/ pOut->SetTextLineColor( Color( COL_LIGHTGRAY ) ); +/*?*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont ) +/*N*/ { +/*N*/ // Fuer Zeilenhoehe bei Hoch/Tief erstmal ohne Propr! +/*N*/ sal_uInt16 nPropr = rFont.GetPropr(); +/*N*/ DBG_ASSERT( ( nPropr == 100 ) || rFont.GetEscapement(), "Propr ohne Escape?!" ); +/*N*/ if ( nPropr != 100 ) +/*N*/ { +/*N*/ rFont.SetPropr( 100 ); +/*N*/ rFont.SetPhysFont( pRefDev ); +/*N*/ } +/*N*/ FontMetric aMetric( pRefDev->GetFontMetric() ); +/*N*/ +/*N*/ sal_uInt16 nAscent = (sal_uInt16)aMetric.GetAscent(); +/*N*/ sal_uInt16 nDescent = (sal_uInt16)aMetric.GetDescent(); +/*N*/ sal_uInt16 nLeading = ( aMetric.GetIntLeading() > 0 ) ? (sal_uInt16)aMetric.GetIntLeading() : 0; +/*N*/ // Fonts ohne Leading bereiten Probleme +/*N*/ if ( ( nLeading == 0 ) && ( pRefDev->GetOutDevType() == OUTDEV_PRINTER ) ) +/*N*/ { +/*N*/ // Da schaun wir mal, was fuer eine Leading ich auf dem +/*N*/ // Bildschirm erhalte +/*N*/ VirtualDevice* pVDev = GetVirtualDevice( pRefDev->GetMapMode() ); +/*N*/ rFont.SetPhysFont( pVDev ); +/*N*/ aMetric = pVDev->GetFontMetric(); +/*N*/ +/*N*/ // Damit sich die Leading nicht wieder rausrechnet, +/*N*/ // wenn die ganze Zeile den Font hat, nTmpLeading. +/*N*/ +/*N*/ // 4/96: Kommt bei HP Laserjet 4V auch nicht hin +/*N*/ // => Werte komplett vom Bildschirm holen. +/*N*/ // sal_uInt16 nTmpLeading = (sal_uInt16)aMetric.GetIntLeading(); +/*N*/ // nAscent += nTmpLeading; +/*N*/ nAscent = (sal_uInt16)aMetric.GetAscent(); +/*N*/ nDescent = (sal_uInt16)aMetric.GetDescent(); +/*N*/ // nLeading = (sal_uInt16)aMetric.GetIntLeading(); +/*N*/ } +/*N*/ if ( nAscent > rCurMetrics.nMaxAscent ) +/*N*/ rCurMetrics.nMaxAscent = nAscent; +/*N*/ if ( nDescent > rCurMetrics.nMaxDescent ) +/*N*/ rCurMetrics.nMaxDescent= nDescent; +/*N*/ +/*N*/ // Sonderbehandlung Hoch/Tief: +/*N*/ if ( rFont.GetEscapement() ) +/*N*/ { +/*N*/ // Jetzt unter Beruecksichtigung von Escape/Propr +/*N*/ // Ascent oder Descent ggf vergroessern +/*N*/ short nDiff = (short)(rFont.GetSize().Height()*rFont.GetEscapement()/100L); +/*N*/ if ( rFont.GetEscapement() > 0 ) +/*N*/ { +/*N*/ nAscent = (sal_uInt16) (((long)nAscent)*nPropr/100 + nDiff); +/*N*/ if ( nAscent > rCurMetrics.nMaxAscent ) +/*N*/ rCurMetrics.nMaxAscent = nAscent; +/*N*/ } +/*N*/ else // muss < 0 sein +/*N*/ { +/*N*/ nDescent = (sal_uInt16) (((long)nDescent)*nPropr/100 - nDiff); +/*N*/ if ( nDescent > rCurMetrics.nMaxDescent ) +/*N*/ rCurMetrics.nMaxDescent= nDescent; +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::Paint( OutputDevice* pOutDev, Rectangle aClipRec, Point aStartPos, sal_Bool bStripOnly, short nOrientation ) +/*N*/ { +/*N*/ if ( !GetUpdateMode() && !bStripOnly ) +/*N*/ return; +/*N*/ +/*N*/ if ( !IsFormatted() ) +/*?*/ FormatDoc(); +/*N*/ +/*N*/ long nFirstVisXPos = - pOutDev->GetMapMode().GetOrigin().X(); +/*N*/ long nFirstVisYPos = - pOutDev->GetMapMode().GetOrigin().Y(); +/*N*/ +/*N*/ EditLine* pLine; +/*N*/ Point aTmpPos; +/*N*/ Point aRedLineTmpPos; +/*N*/ DBG_ASSERT( GetParaPortions().Count(), "Keine ParaPortion?!" ); +/*N*/ SvxFont aTmpFont( GetParaPortions()[0]->GetNode()->GetCharAttribs().GetDefFont() ); +/*N*/ Font aOldFont( pOutDev->GetFont() ); +/*N*/ // Bei gedrehtem Text wird aStartPos als TopLeft angesehen, da andere +/*N*/ // Informationen fehlen, und sowieso das ganze Object ungescrollt +/*N*/ // dargestellt wird. +/*N*/ // Das Rechteck ist unendlich gross. +/*N*/ Point aOrigin( aStartPos ); +/*N*/ double nCos, nSin; +/*N*/ if ( nOrientation ) +/*N*/ { +/*?*/ double nRealOrientation = nOrientation*F_PI1800; +/*?*/ nCos = cos( nRealOrientation ); +/*?*/ nSin = sin( nRealOrientation ); +/*N*/ } +/*N*/ +/*N*/ // Fuer OnlineSpelling: +/*N*/ // EditPaM aCursorPos; +/*N*/ // if( GetStatus().DoOnlineSpelling() && pActiveView ) +/*N*/ // aCurPos = pActiveView->pImpEditView->GetEditSelections().Max(); +/*N*/ +/*N*/ // -------------------------------------------------- +/*N*/ // Ueber alle Absaetze... +/*N*/ // -------------------------------------------------- +/*N*/ for ( sal_uInt16 n = 0; n < GetParaPortions().Count(); n++ ) +/*N*/ { +/*N*/ ParaPortion* pPortion = GetParaPortions().GetObject( n ); +/*N*/ DBG_ASSERT( pPortion, "NULL-Pointer in TokenList in Paint" ); +/*N*/ // falls beim Tippen Idle-Formatierung, asynchrones Paint. +/*N*/ // Unsichtbare Portions koennen ungueltig sein. +/*N*/ if ( pPortion->IsVisible() && pPortion->IsInvalid() ) +/*N*/ return; +/*N*/ long nParaHeight = pPortion->GetHeight(); +/*N*/ sal_uInt16 nIndex = 0; +/*N*/ if ( pPortion->IsVisible() && ( +/*N*/ ( !IsVertical() && ( ( aStartPos.Y() + nParaHeight ) > aClipRec.Top() ) ) || +/*N*/ ( IsVertical() && ( ( aStartPos.X() - nParaHeight ) < aClipRec.Right() ) ) ) ) +/*N*/ +/*N*/ { +/*N*/ // -------------------------------------------------- +/*N*/ // Ueber die Zeilen des Absatzes... +/*N*/ // -------------------------------------------------- +/*N*/ sal_uInt16 nLines = pPortion->GetLines().Count(); +/*N*/ sal_uInt16 nLastLine = nLines-1; +/*N*/ +/*N*/ if ( !IsVertical() ) +/*N*/ aStartPos.Y() += pPortion->GetFirstLineOffset(); +/*N*/ else +/*?*/ aStartPos.X() -= pPortion->GetFirstLineOffset(); +/*N*/ +/*N*/ Point aParaStart( aStartPos ); +/*N*/ +/*N*/ const SvxLineSpacingItem& rLSItem = ((const SvxLineSpacingItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL )); +/*N*/ sal_uInt16 nSBL = ( rLSItem.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) +/*N*/ ? GetYValue( rLSItem.GetInterLineSpace() ) : 0; +/*N*/ for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ ) +/*N*/ { +/*N*/ pLine = pPortion->GetLines().GetObject(nLine); +/*N*/ DBG_ASSERT( pLine, "NULL-Pointer im Zeileniterator in UpdateViews" ); +/*N*/ aTmpPos = aStartPos; +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ aTmpPos.X() += pLine->GetStartPosX(); +/*N*/ aTmpPos.Y() += pLine->GetMaxAscent(); +/*N*/ aStartPos.Y() += pLine->GetHeight(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aTmpPos.Y() += pLine->GetStartPosX(); +/*?*/ aTmpPos.X() -= pLine->GetMaxAscent(); +/*?*/ aStartPos.X() -= pLine->GetHeight(); +/*N*/ } +/*N*/ +/*N*/ if ( ( !IsVertical() && ( aStartPos.Y() > aClipRec.Top() ) ) +/*N*/ || ( IsVertical() && aStartPos.X() < aClipRec.Right() ) ) +/*N*/ { +/*N*/ if ( ( nLine == 0 ) && !bStripOnly ) // erste Zeile +/*N*/ { +/*N*/ // VERT??? +/*N*/ GetEditEnginePtr()->PaintingFirstLine( n, aParaStart, aTmpPos.Y(), aOrigin, nOrientation, pOutDev ); +/*N*/ } +/*N*/ // -------------------------------------------------- +/*N*/ // Ueber die Portions der Zeile... +/*N*/ // -------------------------------------------------- +/*N*/ nIndex = pLine->GetStart(); +/*N*/ for ( sal_uInt16 y = pLine->GetStartPortion(); y <= pLine->GetEndPortion(); y++ ) +/*N*/ { +/*N*/ DBG_ASSERT( pPortion->GetTextPortions().Count(), "Zeile ohne Textportion im Paint!" ); +/*N*/ TextPortion* pTextPortion = pPortion->GetTextPortions().GetObject( y ); +/*N*/ DBG_ASSERT( pTextPortion, "NULL-Pointer im Portioniterator in UpdateViews" ); +/*N*/ +/*N*/ long nPortionXOffset = GetPortionXOffset( pPortion, pLine, y ); +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ aTmpPos.X() = aStartPos.X() + nPortionXOffset; +/*N*/ if ( aTmpPos.X() > aClipRec.Right() ) +/*N*/ break; // Keine weitere Ausgabe in Zeile noetig +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aTmpPos.Y() = aStartPos.Y() + nPortionXOffset; +/*?*/ if ( aTmpPos.Y() > aClipRec.Bottom() ) +/*?*/ break; // Keine weitere Ausgabe in Zeile noetig +/*N*/ } +/*N*/ +/*N*/ // R2L replaces with obove... +/*N*/ // New position after processing R2L text... +/*N*/ // R2L if ( nR2LWidth && !pTextPortion->GetRightToLeft() ) +/*N*/ // R2L { +/*N*/ // R2L if ( !IsVertical() ) +/*N*/ // R2L aTmpPos.X() += nR2LWidth; +/*N*/ // R2L else +/*N*/ // R2L aTmpPos.Y() += nR2LWidth; +/*N*/ // R2L +/*N*/ // R2L nR2LWidth = 0; +/*N*/ // R2L } +/*N*/ +/*N*/ switch ( pTextPortion->GetKind() ) +/*N*/ { +/*N*/ case PORTIONKIND_TEXT: +/*N*/ case PORTIONKIND_FIELD: +/*N*/ case PORTIONKIND_HYPHENATOR: +/*N*/ { +/*N*/ SeekCursor( pPortion->GetNode(), nIndex+1, aTmpFont, pOutDev ); +/*N*/ +/*N*/ BOOL bDrawFrame = FALSE; +/*N*/ +/*N*/ if ( ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) && !aTmpFont.IsTransparent() && +/*N*/ ( GetBackgroundColor() != COL_AUTO ) && GetBackgroundColor().IsDark() && +/*N*/ ( IsAutoColorEnabled() && ( pOutDev->GetOutDevType() != OUTDEV_PRINTER ) ) ) +/*N*/ { +/*?*/ aTmpFont.SetTransparent( TRUE ); +/*?*/ pOutDev->SetFillColor(); +/*?*/ pOutDev->SetLineColor( GetAutoColor() ); +/*?*/ bDrawFrame = TRUE; +/*N*/ } +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ if ( pTextPortion->GetKind() == PORTIONKIND_HYPHENATOR ) +/*N*/ { +/*N*/ aTmpFont.SetFillColor( COL_LIGHTGRAY ); +/*N*/ aTmpFont.SetTransparent( sal_False ); +/*N*/ } +/*N*/ if ( pTextPortion->GetRightToLeft() ) +/*N*/ { +/*N*/ aTmpFont.SetFillColor( COL_LIGHTGRAY ); +/*N*/ aTmpFont.SetTransparent( sal_False ); +/*N*/ } +/*N*/ else if ( GetScriptType( EditPaM( pPortion->GetNode(), nIndex+1 ) ) == i18n::ScriptType::COMPLEX ) +/*N*/ { +/*N*/ aTmpFont.SetFillColor( COL_LIGHTCYAN ); +/*N*/ aTmpFont.SetTransparent( sal_False ); +/*N*/ } +/*N*/ #endif +/*N*/ aTmpFont.SetPhysFont( pOutDev ); +/*N*/ +/*N*/ ULONG nOldLayoutMode = pOutDev->GetLayoutMode(); +/*N*/ ImplInitLayoutMode( pOutDev, n, nIndex ); +/*N*/ +/*N*/ XubString aText; +/*N*/ USHORT nTextStart = 0; +/*N*/ USHORT nTextLen = 0; +/*N*/ const sal_Int32* pDXArray = 0; +/*N*/ sal_Int32* pTmpDXArray = 0; +/*N*/ +/*N*/ if ( pTextPortion->GetKind() == PORTIONKIND_TEXT ) +/*N*/ { +/*N*/ aText = *pPortion->GetNode(); +/*N*/ nTextStart = nIndex; +/*N*/ nTextLen = pTextPortion->GetLen(); +/*N*/ pDXArray = pLine->GetCharPosArray().GetData()+( nIndex-pLine->GetStart() ); +/*N*/ } +/*N*/ else if ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) +/*N*/ { +/*?*/ EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature( nIndex ); +/*?*/ DBG_ASSERT( pAttr, "Feld nicht gefunden" ); +/*?*/ DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Feld vom falschen Typ!" ); +/*?*/ aText = ((EditCharAttribField*)pAttr)->GetFieldValue(); +/*?*/ nTextStart = 0; +/*?*/ nTextLen = aText.Len(); +/*?*/ +/*?*/ pTmpDXArray = new sal_Int32[ aText.Len() ]; +/*?*/ pDXArray = pTmpDXArray; +/*?*/ Font aOldFont( GetRefDevice()->GetFont() ); +/*?*/ aTmpFont.SetPhysFont( GetRefDevice() ); +/*?*/ aTmpFont.QuickGetTextSize( GetRefDevice(), aText, 0, aText.Len(), pTmpDXArray ); +/*?*/ if ( aStatus.DoRestoreFont() ) +/*?*/ GetRefDevice()->SetFont( aOldFont ); +/*?*/ +/*?*/ // add a meta file comment if we record to a metafile +/*?*/ GDIMetaFile* pMtf = pOutDev->GetConnectMetaFile(); +/*?*/ if( pMtf ) +/*?*/ { +/*?*/ SvxFieldItem* pFieldItem = PTR_CAST( SvxFieldItem, pAttr->GetItem() ); +/*?*/ +/*?*/ if( pFieldItem ) +/*?*/ { +/*?*/ const SvxFieldData* pFieldData = pFieldItem->GetField(); +/*?*/ if( pFieldData ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");}//STRIP001 pMtf->AddAction( pFieldData->createBeginComment() ); +/*?*/ } +/*?*/ } +/*?*/ +/*?*/ } +/*N*/ else if ( pTextPortion->GetKind() == PORTIONKIND_HYPHENATOR ) +/*N*/ { +/*N*/ if ( pTextPortion->GetExtraValue() ) +/*N*/ aText = pTextPortion->GetExtraValue(); +/*N*/ aText += CH_HYPH; +/*N*/ nTextStart = 0; +/*N*/ nTextLen = aText.Len(); +/*N*/ } +/*N*/ +/*N*/ long nTxtWidth = pTextPortion->GetSize().Width(); +/*N*/ +/*N*/ Point aOutPos( aTmpPos ); +/*N*/ aRedLineTmpPos = aTmpPos; +/*N*/ //L2R if ( pTextPortion->GetRightToLeft() ) +/*N*/ //L2R { +/*N*/ //L2R sal_uInt16 nNextPortion = y+1; +/*N*/ //L2R while ( nNextPortion <= pLine->GetEndPortion() ) +/*N*/ //L2R { +/*N*/ //L2R TextPortion* pNextTextPortion = pPortion->GetTextPortions().GetObject( nNextPortion ); +/*N*/ //L2R if ( pNextTextPortion->GetRightToLeft() ) +/*N*/ //L2R { +/*N*/ //L2R if ( !IsVertical() ) +/*N*/ //L2R aOutPos.X() += pNextTextPortion->GetSize().Width(); +/*N*/ //L2R else +/*N*/ //L2R aOutPos.Y() += pNextTextPortion->GetSize().Width(); +/*N*/ //L2R } +/*N*/ //L2R else +/*N*/ //L2R break; +/*N*/ //L2R nNextPortion++; +/*N*/ //L2R } +/*N*/ //L2R } +/*N*/ if ( bStripOnly ) +/*N*/ { +/*N*/ // VERT??? +/*N*/ GetEditEnginePtr()->DrawingText( aOutPos, aText, nTextStart, nTextLen, pDXArray, aTmpFont, n, nIndex, pTextPortion->GetRightToLeft() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ short nEsc = aTmpFont.GetEscapement(); +/*N*/ if ( nOrientation ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 // Bei Hoch/Tief selbst Hand anlegen: +/*N*/ } +/*N*/ // nur ausgeben, was im sichtbaren Bereich beginnt: +/*N*/ // Wichtig, weil Bug bei einigen Grafikkarten bei transparentem Font, Ausgabe bei neg. +/*N*/ if ( nOrientation || ( !IsVertical() && ( ( aTmpPos.X() + nTxtWidth ) >= nFirstVisXPos ) ) +/*N*/ || ( IsVertical() && ( ( aTmpPos.Y() + nTxtWidth ) >= nFirstVisYPos ) ) ) +/*N*/ { +/*N*/ if ( nEsc && ( ( aTmpFont.GetUnderline() != UNDERLINE_NONE ) ) ) +/*N*/ { +/*?*/ // Das Hoch/Tief ohne Underline malen, das Underline +/*?*/ // auf der BaseLine der Original-Fonthoehe ausgeben... +/*?*/ +/*?*/ // Aber nur, wenn davor auch Unterstrichen! +/*?*/ sal_Bool bSpecialUnderline = sal_False; +/*?*/ EditCharAttrib* pPrev = pPortion->GetNode()->GetCharAttribs().FindAttrib( EE_CHAR_ESCAPEMENT, nIndex ); +/*?*/ if ( pPrev ) +/*?*/ { +/*?*/ SvxFont aDummy; +/*?*/ // Unterstreichung davor? +/*?*/ if ( pPrev->GetStart() ) +/*?*/ { +/*?*/ SeekCursor( pPortion->GetNode(), pPrev->GetStart(), aDummy ); +/*?*/ if ( aDummy.GetUnderline() != UNDERLINE_NONE ) +/*?*/ bSpecialUnderline = sal_True; +/*?*/ } +/*?*/ if ( !bSpecialUnderline && ( pPrev->GetEnd() < pPortion->GetNode()->Len() ) ) +/*?*/ { +/*?*/ SeekCursor( pPortion->GetNode(), pPrev->GetEnd()+1, aDummy ); +/*?*/ if ( aDummy.GetUnderline() != UNDERLINE_NONE ) +/*?*/ bSpecialUnderline = sal_True; +/*?*/ } +/*?*/ } +/*?*/ if ( bSpecialUnderline ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 Size aSz = aTmpFont.GetPhysTxtSize( pOutDev, aText, nTextStart, nTextLen ); +/*?*/ } +/*N*/ } +/*N*/ Point aRealOutPos( aOutPos ); +/*N*/ if ( ( pTextPortion->GetKind() == PORTIONKIND_TEXT ) +/*N*/ && pTextPortion->GetExtraInfos() && pTextPortion->GetExtraInfos()->bCompressed +/*N*/ && pTextPortion->GetExtraInfos()->bFirstCharIsRightPunktuation ) +/*N*/ { +/*?*/ aRealOutPos.X() += pTextPortion->GetExtraInfos()->nPortionOffsetX; +/*N*/ } +/*N*/ +/*N*/ aTmpFont.QuickDrawText( pOutDev, aRealOutPos, aText, nTextStart, nTextLen, pDXArray ); +/*N*/ if ( bDrawFrame ) +/*N*/ { +/*?*/ Point aTopLeft( aTmpPos ); +/*?*/ aTopLeft.Y() -= pLine->GetMaxAscent(); +/*?*/ if ( nOrientation ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 aTopLeft = lcl_ImplCalcRotatedPos( aTopLeft, aOrigin, nSin, nCos ); +/*?*/ Rectangle aRect( aTopLeft, pTextPortion->GetSize() ); +/*?*/ pOutDev->DrawRect( aRect ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ pOutDev->SetLayoutMode( nOldLayoutMode ); +/*N*/ +/*N*/ if ( pTmpDXArray ) +/*?*/ delete[] pTmpDXArray; +/*N*/ +/*N*/ // R2L if ( !pTextPortion->GetRightToLeft() ) +/*N*/ // R2L { +/*N*/ // R2L if ( !IsVertical() ) +/*N*/ // R2L aTmpPos.X() += nTxtWidth; +/*N*/ // R2L else +/*N*/ // R2L aTmpPos.Y() += nTxtWidth; +/*N*/ // R2L } +/*N*/ // R2L else +/*N*/ // R2L { +/*N*/ // R2L nR2LWidth += nTxtWidth; +/*N*/ // R2L } +/*N*/ +/*N*/ if ( pTextPortion->GetKind() == PORTIONKIND_FIELD ) +/*N*/ { +/*?*/ EditCharAttrib* pAttr = pPortion->GetNode()->GetCharAttribs().FindFeature( nIndex ); +/*?*/ DBG_ASSERT( pAttr, "Feld nicht gefunden" ); +/*?*/ DBG_ASSERT( pAttr && pAttr->GetItem()->ISA( SvxFieldItem ), "Feld vom falschen Typ!" ); +/*?*/ +/*?*/ // add a meta file comment if we record to a metafile +/*?*/ GDIMetaFile* pMtf = pOutDev->GetConnectMetaFile(); +/*?*/ if( pMtf ) +/*?*/ { +/*?*/ SvxFieldItem* pFieldItem = PTR_CAST( SvxFieldItem, pAttr->GetItem() ); +/*?*/ +/*?*/ if( pFieldItem ) +/*?*/ { +/*?*/ const SvxFieldData* pFieldData = pFieldItem->GetField(); +/*?*/ if( pFieldData ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");}//STRIP001 pMtf->AddAction( pFieldData->createEndComment() ); +/*?*/ } +/*?*/ } +/*?*/ +/*N*/ } +/*N*/ +/*N*/ } +/*N*/ break; +/*N*/ // case PORTIONKIND_EXTRASPACE: +/*N*/ case PORTIONKIND_TAB: +/*N*/ { +/*?*/ if ( pTextPortion->GetExtraValue() && ( pTextPortion->GetExtraValue() != ' ' ) ) +/*?*/ { +/*?*/ SeekCursor( pPortion->GetNode(), nIndex+1, aTmpFont, pOutDev ); +/*?*/ aTmpFont.SetTransparent( sal_False ); +/*?*/ aTmpFont.SetEscapement( 0 ); +/*?*/ aTmpFont.SetPhysFont( pOutDev ); +/*?*/ long nCharWidth = aTmpFont.QuickGetTextSize( pOutDev, pTextPortion->GetExtraValue(), 0, 1, NULL ).Width(); +/*?*/ long nChars = pTextPortion->GetSize().Width() / nCharWidth; +/*?*/ if ( nChars < 2 ) +/*?*/ nChars = 2; // wird durch DrawStretchText gestaucht. +/*?*/ else if ( nChars == 2 ) +/*?*/ nChars = 3; // sieht besser aus +/*?*/ +/*?*/ String aText; +/*?*/ aText.Fill( (USHORT)nChars, pTextPortion->GetExtraValue() ); +/*?*/ pOutDev->DrawStretchText( aTmpPos, pTextPortion->GetSize().Width(), aText ); +/*?*/ } +/*?*/ // R2L if ( !IsVertical() ) +/*?*/ // R2L aTmpPos.X() += pTextPortion->GetSize().Width(); +/*?*/ // R2L else +/*?*/ // R2L aTmpPos.Y() += pTextPortion->GetSize().Width(); +/*N*/ } +/*N*/ break; +/*N*/ } +/*N*/ // R2L if ( !IsVertical() && ( aTmpPos.X() > aClipRec.Right() ) ) +/*N*/ // R2L break; // Keine weitere Ausgabe in Zeile noetig +/*N*/ // R2L else if ( IsVertical() && ( aTmpPos.Y() > aClipRec.Bottom() ) ) +/*N*/ // R2L break; // Keine weitere Ausgabe in Zeile noetig +/*N*/ nIndex += pTextPortion->GetLen(); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( ( nLine != nLastLine ) && !aStatus.IsOutliner() ) +/*N*/ { +/*?*/ if ( !IsVertical() ) +/*?*/ aStartPos.Y() += nSBL; +/*?*/ else +/*?*/ aStartPos.X() -= nSBL; +/*N*/ } +/*N*/ +/*N*/ // keine sichtbaren Aktionen mehr? +/*N*/ if ( !IsVertical() && ( aStartPos.Y() >= aClipRec.Bottom() ) ) +/*N*/ break; +/*N*/ else if ( IsVertical() && ( aStartPos.X() <= aClipRec.Left() ) ) +/*N*/ break; +/*N*/ } +/*N*/ +/*N*/ if ( !aStatus.IsOutliner() ) +/*N*/ { +/*N*/ const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE ); +/*N*/ long nUL = GetYValue( rULItem.GetLower() ); +/*N*/ if ( !IsVertical() ) +/*N*/ aStartPos.Y() += nUL; +/*N*/ else +/*N*/ aStartPos.X() -= nUL; +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ if ( !IsVertical() ) +/*?*/ aStartPos.Y() += nParaHeight; +/*?*/ else +/*?*/ aStartPos.X() -= nParaHeight; +/*N*/ } +/*N*/ +/*N*/ // keine sichtbaren Aktionen mehr? +/*N*/ if ( !IsVertical() && ( aStartPos.Y() > aClipRec.Bottom() ) ) +/*N*/ break; +/*N*/ if ( IsVertical() && ( aStartPos.X() < aClipRec.Left() ) ) +/*N*/ break; +/*N*/ } +/*N*/ if ( aStatus.DoRestoreFont() ) +/*?*/ pOutDev->SetFont( aOldFont ); +/*N*/ } + +/*N*/ void ImpEditEngine::Paint( ImpEditView* pView, const Rectangle& rRec, sal_Bool bUseVirtDev ) +/*N*/ { +/*N*/ DBG_ASSERT( pView, "Keine View - Kein Paint!" ); +/*N*/ DBG_CHKOBJ( GetEditEnginePtr(), EditEngine, 0 ); +/*N*/ +/*N*/ if ( !GetUpdateMode() || IsInUndo() ) +/*N*/ return; +/*N*/ +/*N*/ // Schnittmenge aus Paintbereich und OutputArea. +/*N*/ Rectangle aClipRec( pView->GetOutputArea() ); +/*N*/ aClipRec.Intersection( rRec ); +/*N*/ +/*N*/ Window* pOutWin = pView->GetWindow(); +/*N*/ +/*N*/ if ( bUseVirtDev ) +/*N*/ { +/*N*/ Rectangle aClipRecPixel( pOutWin->LogicToPixel( aClipRec ) ); +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ // etwas mehr, falls abgerundet! +/*N*/ aClipRecPixel.Right() += 1; +/*N*/ aClipRecPixel.Bottom() += 1; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aClipRecPixel.Left() -= 1; +/*?*/ aClipRecPixel.Bottom() += 1; +/*N*/ } +/*N*/ +/*N*/ // Wenn aClipRecPixel > XXXX, dann invalidieren ?! +/*N*/ +/*N*/ VirtualDevice* pVDev = GetVirtualDevice( pOutWin->GetMapMode() ); +/*N*/ pVDev->SetDigitLanguage( GetRefDevice()->GetDigitLanguage() ); +/*N*/ +/*N*/ pVDev->SetBackground( pView->GetBackgroundColor() ); +/*N*/ +/*N*/ sal_Bool bVDevValid = sal_True; +/*N*/ Size aOutSz( pVDev->GetOutputSizePixel() ); +/*N*/ if ( ( aOutSz.Width() < aClipRecPixel.GetWidth() ) || +/*N*/ ( aOutSz.Height() < aClipRecPixel.GetHeight() ) ) +/*N*/ { +/*N*/ bVDevValid = pVDev->SetOutputSizePixel( aClipRecPixel.GetSize() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Das VirtDev kann bei einem Resize sehr gross werden => +/*N*/ // irgendwann mal kleiner machen! +/*N*/ if ( ( aOutSz.Height() > ( aClipRecPixel.GetHeight() + RESDIFF ) ) || +/*N*/ ( aOutSz.Width() > ( aClipRecPixel.GetWidth() + RESDIFF ) ) ) +/*N*/ { +/*?*/ bVDevValid = pVDev->SetOutputSizePixel( aClipRecPixel.GetSize() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ pVDev->Erase(); +/*N*/ } +/*N*/ } +/*N*/ DBG_ASSERT( bVDevValid, "VDef konnte nicht vergroessert werden!" ); +/*N*/ if ( !bVDevValid ) +/*N*/ { +/*?*/ Paint( pView, rRec, sal_False /* ohne VDev */ ); +/*?*/ return; +/*N*/ } +/*N*/ +/*N*/ // PaintRect fuer VDev nicht mit alignter Groesse, +/*N*/ // da sonst die Zeile darunter auch ausgegeben werden muss: +/*N*/ Rectangle aTmpRec( Point( 0, 0 ), aClipRec.GetSize() ); +/*N*/ +/*N*/ aClipRec = pOutWin->PixelToLogic( aClipRecPixel ); +/*N*/ Point aStartPos; +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ aStartPos = aClipRec.TopLeft(); +/*N*/ aStartPos = pView->GetDocPos( aStartPos ); +/*N*/ aStartPos.X() *= (-1); +/*N*/ aStartPos.Y() *= (-1); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ aStartPos = aClipRec.TopRight(); +/*?*/ Point aDocPos( pView->GetDocPos( aStartPos ) ); +/*?*/ aStartPos.X() = aClipRec.GetSize().Width() + aDocPos.Y(); +/*?*/ aStartPos.Y() = -aDocPos.X(); +/*N*/ } +/*N*/ +/*N*/ Paint( pVDev, aTmpRec, aStartPos ); +/*N*/ +/*N*/ sal_Bool bClipRegion; +/*N*/ Region aOldRegion; +/*N*/ MapMode aOldMapMode; +/*N*/ if ( GetTextRanger() ) +/*N*/ { +/*?*/ // Some problems here with push/pop, why?! +/*?*/ // pOutWin->Push( PUSH_CLIPREGION|PUSH_MAPMODE ); +/*?*/ bClipRegion = pOutWin->IsClipRegion(); +/*?*/ aOldRegion = pOutWin->GetClipRegion(); +/*?*/ // Wie bekomme ich das Polygon an die richtige Stelle???? +/*?*/ // Das Polygon bezieht sich auf die View, nicht auf das Window +/*?*/ // => Origin umsetzen... +/*?*/ aOldMapMode = pOutWin->GetMapMode(); +/*?*/ Point aOrigin = aOldMapMode.GetOrigin(); +/*?*/ Point aViewPos = pView->GetOutputArea().TopLeft(); +/*?*/ aOrigin.Move( aViewPos.X(), aViewPos.Y() ); +/*?*/ aClipRec.Move( -aViewPos.X(), -aViewPos.Y() ); +/*?*/ MapMode aNewMapMode( aOldMapMode ); +/*?*/ aNewMapMode.SetOrigin( aOrigin ); +/*?*/ pOutWin->SetMapMode( aNewMapMode ); +/*?*/ pOutWin->SetClipRegion( Region( GetTextRanger()->GetPolyPolygon() ) ); +/*N*/ } +/*N*/ +/*N*/ pOutWin->DrawOutDev( aClipRec.TopLeft(), aClipRec.GetSize(), +/*N*/ Point(0,0), aClipRec.GetSize(), *pVDev ); +/*N*/ +/*N*/ if ( GetTextRanger() ) +/*N*/ { +/*?*/ // pOutWin->Pop(); +/*?*/ if ( bClipRegion ) +/*?*/ pOutWin->SetClipRegion( aOldRegion ); +/*?*/ else +/*?*/ pOutWin->SetClipRegion(); +/*?*/ pOutWin->SetMapMode( aOldMapMode ); +/*N*/ } +/*N*/ +/*N*/ +/*N*/ pView->DrawSelection(); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ Point aStartPos; +/*?*/ if ( !IsVertical() ) +/*?*/ { +/*?*/ aStartPos = pView->GetOutputArea().TopLeft(); +/*?*/ aStartPos.X() -= pView->GetVisDocLeft(); +/*?*/ aStartPos.Y() -= pView->GetVisDocTop(); +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ aStartPos = pView->GetOutputArea().TopRight(); +/*?*/ aStartPos.X() += pView->GetVisDocTop(); +/*?*/ aStartPos.Y() -= pView->GetVisDocLeft(); +/*?*/ } +/*?*/ +/*?*/ // Wenn Doc-Breite < OutputArea,Width, nicht umgebrochene Felder, +/*?*/ // stehen die Felder sonst ber, wenn > Zeile. +/*?*/ // ( Oben nicht, da dort bereits Doc-Breite von Formatierung mit drin ) +/*?*/ if ( !IsVertical() && ( pView->GetOutputArea().GetWidth() > GetPaperSize().Width() ) ) +/*?*/ { +/*?*/ long nMaxX = pView->GetOutputArea().Left() + GetPaperSize().Width(); +/*?*/ if ( aClipRec.Left() > nMaxX ) +/*?*/ return; +/*?*/ if ( aClipRec.Right() > nMaxX ) +/*?*/ aClipRec.Right() = nMaxX; +/*?*/ } +/*?*/ +/*?*/ sal_Bool bClipRegion = pOutWin->IsClipRegion(); +/*?*/ Region aOldRegion = pOutWin->GetClipRegion(); +/*?*/ pOutWin->IntersectClipRegion( aClipRec ); +/*?*/ +/*?*/ Paint( pOutWin, aClipRec, aStartPos ); +/*?*/ +/*?*/ if ( bClipRegion ) +/*?*/ pOutWin->SetClipRegion( aOldRegion ); +/*?*/ else +/*?*/ pOutWin->SetClipRegion(); +/*?*/ +/*?*/ pView->DrawSelection(); +/*N*/ } +/*N*/ +/*N*/ } + + + + +/*N*/ void ImpEditEngine::SetUpdateMode( sal_Bool bUp, EditView* pCurView, sal_Bool bForceUpdate ) +/*N*/ { +/*N*/ sal_Bool bChanged = ( GetUpdateMode() != bUp ); +/*N*/ +/*N*/ // Beim Umschalten von sal_True auf sal_False waren alle Selektionen sichtbar, +/*N*/ // => Wegmalen +/*N*/ // Umgekehrt waren alle unsichtbar => malen +/*N*/ +/*N*/ // DrawAllSelections(); sieht im Outliner schlecht aus ! +/*N*/ // EditView* pView = aEditViewList.First(); +/*N*/ // while ( pView ) +/*N*/ // { +/*N*/ // DBG_CHKOBJ( pView, EditView, 0 ); +/*N*/ // pView->pImpEditView->DrawSelection(); +/*N*/ // pView = aEditViewList.Next(); +/*N*/ // } +/*N*/ +/*N*/ // Wenn !bFormatted, also z.B. nach SetText, braucht bei UpdateMode sal_True +/*N*/ // nicht sofort formatiert werden, weil warscheinlich noch Text kommt. +/*N*/ // Spaetestens bei einem Paint / CalcTextWidth wird formatiert. +/*N*/ +/*N*/ bUpdate = bUp; +/*N*/ if ( bUpdate && ( bChanged || bForceUpdate ) ) +/*N*/ FormatAndUpdate( pCurView ); +/*N*/ } + +/*N*/ EditPaM ImpEditEngine::InsertParagraph( sal_uInt16 nPara ) +/*N*/ { +/*N*/ EditPaM aPaM; +/*N*/ if ( nPara != 0 ) +/*N*/ { +/*N*/ ContentNode* pNode = GetEditDoc().SaveGetObject( nPara-1 ); +/*N*/ if ( !pNode ) +/*?*/ pNode = GetEditDoc().SaveGetObject( GetEditDoc().Count() - 1 ); +/*N*/ DBG_ASSERT( pNode, "Kein einziger Absatz in InsertParagraph ?" ); +/*N*/ aPaM = EditPaM( pNode, pNode->Len() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ ContentNode* pNode = GetEditDoc().SaveGetObject( 0 ); +/*?*/ aPaM = EditPaM( pNode, 0 ); +/*N*/ } +/*N*/ +/*N*/ return ImpInsertParaBreak( aPaM ); +/*N*/ } + +/*N*/ EditSelection* ImpEditEngine::SelectParagraph( sal_uInt16 nPara ) +/*N*/ { +/*N*/ EditSelection* pSel = 0; +/*N*/ ContentNode* pNode = GetEditDoc().SaveGetObject( nPara ); +/*N*/ DBG_ASSERTWARNING( pNode, "Absatz existiert nicht: SelectParagraph" ); +/*N*/ if ( pNode ) +/*N*/ pSel = new EditSelection( EditPaM( pNode, 0 ), EditPaM( pNode, pNode->Len() ) ); +/*N*/ +/*N*/ return pSel; +/*N*/ } + +/*N*/ void ImpEditEngine::FormatAndUpdate( EditView* pCurView ) +/*N*/ { +/*N*/ if ( bDowning ) +/*N*/ return ; +/*N*/ +/*N*/ { +/*N*/ FormatDoc(); +/*N*/ UpdateViews( pCurView ); +/*N*/ } +/*N*/ } + + +/*N*/ void ImpEditEngine::SetCharStretching( sal_uInt16 nX, sal_uInt16 nY ) +/*N*/ { +/*N*/ if ( !IsVertical() ) +/*N*/ { +/*N*/ nStretchX = nX; +/*N*/ nStretchY = nY; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStretchX = nY; +/*N*/ nStretchY = nX; +/*N*/ } +/*N*/ +/*N*/ if ( aStatus.DoStretch() ) +/*N*/ { +/*?*/ FormatFullDoc(); +/*?*/ UpdateViews( GetActiveView() ); +/*N*/ } +/*N*/ } + +/*N*/ const SvxLRSpaceItem& ImpEditEngine::GetLRSpaceItem( ContentNode* pNode ) +/*N*/ { +/*N*/ return (const SvxLRSpaceItem&)pNode->GetContentAttribs().GetItem( aStatus.IsOutliner() ? EE_PARA_OUTLLRSPACE : EE_PARA_LRSPACE ); +/*N*/ } + +/*N*/ void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, USHORT nPara, USHORT nIndex ) +/*N*/ { +/*N*/ BOOL bCTL = FALSE; +/*N*/ BYTE bR2L = FALSE; +/*N*/ if ( nIndex == 0xFFFF ) +/*N*/ { +/*N*/ bCTL = HasScriptType( nPara, i18n::ScriptType::COMPLEX ); +/*N*/ bR2L = IsRightToLeft( nPara ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ ContentNode* pNode = GetEditDoc().SaveGetObject( nPara ); +/*N*/ short nScriptType = GetScriptType( EditPaM( pNode, nIndex+1 ) ); +/*N*/ bCTL = nScriptType == i18n::ScriptType::COMPLEX; +/*N*/ bR2L = GetRightToLeft( nPara, nIndex ); +/*N*/ } +/*N*/ +/*N*/ ULONG nLayoutMode = pOutDev->GetLayoutMode(); +/*N*/ +/*N*/ // We always use the left postion for DrawText() +/*N*/ nLayoutMode &= ~(TEXT_LAYOUT_BIDI_RTL); +/*N*/ +/*N*/ if ( !bCTL && !bR2L) +/*N*/ { +/*?*/ // No CTL/Bidi checking neccessary +/*?*/ nLayoutMode |= ( TEXT_LAYOUT_COMPLEX_DISABLED | TEXT_LAYOUT_BIDI_STRONG ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // CTL/Bidi checking neccessary +/*N*/ // Don't use BIDI_STRONG, VCL must do some checks. +/*N*/ nLayoutMode &= ~( TEXT_LAYOUT_COMPLEX_DISABLED | TEXT_LAYOUT_BIDI_STRONG ); +/*N*/ +/*N*/ if ( bR2L ) +/*N*/ nLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT; +/*N*/ } +/*N*/ +/*N*/ pOutDev->SetLayoutMode( nLayoutMode ); +/*N*/ +/*N*/ } + +/*N*/ Reference < i18n::XBreakIterator > ImpEditEngine::ImplGetBreakIterator() +/*N*/ { +/*N*/ if ( !xBI.is() ) +/*N*/ { +/*N*/ Reference< lang::XMultiServiceFactory > xMSF = ::legacy_binfilters::getLegacyProcessServiceFactory(); +/*N*/ Reference < XInterface > xI = xMSF->createInstance( OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ); +/*N*/ if ( xI.is() ) +/*N*/ { +/*N*/ Any x = xI->queryInterface( ::getCppuType((const Reference< i18n::XBreakIterator >*)0) ); +/*N*/ x >>= xBI; +/*N*/ } +/*N*/ } +/*N*/ return xBI; +/*N*/ } + +/*N*/ Color ImpEditEngine::GetAutoColor() const +/*N*/ { +/*N*/ Color aColor = const_cast<ImpEditEngine*>(this)->GetColorConfig().GetColorValue( FONTCOLOR ).nColor; +/*N*/ +/*N*/ if ( GetBackgroundColor() != COL_AUTO ) +/*N*/ { +/*?*/ if ( GetBackgroundColor().IsDark() && aColor.IsDark() ) +/*?*/ aColor = COL_WHITE; +/*?*/ else if ( GetBackgroundColor().IsBright() && aColor.IsBright() ) +/*?*/ aColor = COL_BLACK; +/*N*/ } +/*N*/ +/*N*/ return aColor; +/*N*/ } + + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_impedit4.cxx b/binfilter/bf_svx/source/editeng/svx_impedit4.cxx new file mode 100644 index 000000000000..b5a0ad3903b3 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_impedit4.cxx @@ -0,0 +1,533 @@ +/* -*- 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. + * + ************************************************************************/ + + +#include <vcl/svapp.hxx> +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include "eeitem.hxx" +#include "eeitemid.hxx" + +#include <vcl/window.hxx> + +#include <impedit.hxx> + +#include "lrspitem.hxx" +#include "langitem.hxx" + +#include <rtl/tencinfo.h> + +#include <unolingu.hxx> + +namespace binfilter { +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::linguistic2; + + + + + + + + +#ifndef SVX_LIGHT +#endif + + + + + +#ifndef SVX_LIGHT +#endif + + + + + + +/*N*/ EditTextObject* ImpEditEngine::CreateTextObject() +/*N*/ { +/*N*/ EditSelection aCompleteSelection; +/*N*/ aCompleteSelection.Min() = aEditDoc.GetStartPaM(); +/*N*/ aCompleteSelection.Max() = aEditDoc.GetEndPaM(); +/*N*/ +/*N*/ return CreateTextObject( aCompleteSelection ); +/*N*/ } + +/*N*/ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel ) +/*N*/ { +/*N*/ return CreateBinTextObject( aSel, GetEditTextObjectPool(), aStatus.AllowBigObjects(), nBigTextObjectStart ); +/*N*/ } + +/*N*/ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemPool* pPool, sal_Bool bAllowBigObjects, sal_uInt16 nBigObjectStart ) const +/*N*/ { +/*N*/ BinTextObject* pTxtObj = new BinTextObject( pPool ); +/*N*/ pTxtObj->SetVertical( IsVertical() ); +/*N*/ MapUnit eMapUnit = (MapUnit)aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); +/*N*/ pTxtObj->SetMetric( (sal_uInt16) eMapUnit ); +/*N*/ if ( pTxtObj->IsOwnerOfPool() ) +/*N*/ pTxtObj->GetPool()->SetDefaultMetric( (SfxMapUnit) eMapUnit ); +/*N*/ +/*N*/ sal_uInt16 nStartNode, nEndNode; +/*N*/ sal_uInt32 nTextPortions = 0; +/*N*/ +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); +/*N*/ nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); +/*N*/ +/*N*/ sal_Bool bOnlyFullParagraphs = ( aSel.Min().GetIndex() || +/*N*/ ( aSel.Max().GetIndex() < aSel.Max().GetNode()->Len() ) ) ? +/*N*/ sal_False : sal_True; +/*N*/ +/*N*/ // Vorlagen werden nicht gespeichert! +/*N*/ // ( Nur Name und Familie, Vorlage selbst muss in App stehen! ) +/*N*/ +/*N*/ pTxtObj->SetScriptType( GetScriptType( aSel ) ); +/*N*/ +/*N*/ // ueber die Absaetze iterieren... +/*N*/ sal_uInt16 nNode; +/*N*/ for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nNode ); +/*N*/ DBG_ASSERT( pNode, "Node nicht gefunden: Search&Replace" ); +/*N*/ +/*N*/ if ( bOnlyFullParagraphs ) +/*N*/ { +/*N*/ ParaPortion* pParaPortion = GetParaPortions()[nNode]; +/*N*/ nTextPortions += pParaPortion->GetTextPortions().Count(); +/*N*/ } +/*N*/ +/*N*/ sal_uInt16 nStartPos = 0; +/*N*/ sal_uInt16 nEndPos = pNode->Len(); +/*N*/ +/*N*/ sal_Bool bEmptyPara = nEndPos ? sal_False : sal_True; +/*N*/ +/*N*/ if ( ( nNode == nStartNode ) && !bOnlyFullParagraphs ) +/*?*/ nStartPos = aSel.Min().GetIndex(); +/*N*/ if ( ( nNode == nEndNode ) && !bOnlyFullParagraphs ) +/*?*/ nEndPos = aSel.Max().GetIndex(); +/*N*/ +/*N*/ +/*N*/ ContentInfo* pC = pTxtObj->CreateAndInsertContent(); +/*N*/ +/*N*/ // Die Absatzattribute... +/*N*/ pC->GetParaAttribs().Set( pNode->GetContentAttribs().GetItems() ); +/*N*/ +/*N*/ // Seit der 5.1 werden im Outliner die LRSpaceItems anders interpretiert. +/*N*/ // Damit sie in einer 5.0 und aelter richtig sind, muss das Flag +/*N*/ // richtig gesetzt sein... +/*N*/ sal_Bool bOutliner = aStatus.IsAnyOutliner(); +/*N*/ for ( sal_uInt16 n = 0; n <=1; n++ ) +/*N*/ { +/*N*/ sal_uInt16 nItemId = n ? EE_PARA_LRSPACE : EE_PARA_OUTLLRSPACE; +/*N*/ if ( pC->GetParaAttribs().GetItemState( nItemId ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&) pC->GetParaAttribs().Get( nItemId ); +/*N*/ if ( rItem.IsBulletFI() != bOutliner ) +/*N*/ { +/*N*/ SvxLRSpaceItem aNewItem( rItem ); +/*N*/ aNewItem.SetBulletFI( bOutliner ); +/*N*/ pC->GetParaAttribs().Put( aNewItem ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ +/*N*/ // Das StyleSheet... +/*N*/ if ( pNode->GetStyleSheet() ) +/*N*/ { +/*N*/ pC->GetStyle() = pNode->GetStyleSheet()->GetName(); +/*N*/ pC->GetFamily() = pNode->GetStyleSheet()->GetFamily(); +/*N*/ } +/*N*/ +/*N*/ // Der Text... +/*N*/ pC->GetText() = pNode->Copy( nStartPos, nEndPos-nStartPos ); +/*N*/ +/*N*/ // und die Attribute... +/*N*/ sal_uInt16 nAttr = 0; +/*N*/ EditCharAttrib* pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ // In einem leeren Absatz die Attribute behalten! +/*N*/ if ( bEmptyPara || +/*N*/ ( ( pAttr->GetEnd() > nStartPos ) && ( pAttr->GetStart() < nEndPos ) ) ) +/*N*/ { +/*N*/ XEditAttribute* pX = pTxtObj->CreateAttrib( *pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd() ); +/*N*/ // Evtl. korrigieren... +/*N*/ if ( ( nNode == nStartNode ) && ( nStartPos != 0 ) ) +/*N*/ { +/*?*/ pX->GetStart() = ( pX->GetStart() > nStartPos ) ? pX->GetStart()-nStartPos : 0; +/*?*/ pX->GetEnd() -= nStartPos; +/*N*/ +/*N*/ } +/*N*/ if ( nNode == nEndNode ) +/*N*/ { +/*N*/ if ( pX->GetEnd() > (nEndPos-nStartPos) ) +/*?*/ pX->GetEnd() = nEndPos-nStartPos; +/*N*/ } +/*N*/ DBG_ASSERT( pX->GetEnd() <= (nEndPos-nStartPos), "CreateBinTextObject: Attribut zu lang!" ); +/*N*/ if ( !pX->GetLen() && !bEmptyPara ) +/*?*/ pTxtObj->DestroyAttrib( pX ); +/*N*/ else +/*N*/ pC->GetAttribs().Insert( pX, pC->GetAttribs().Count() ); +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Bei grossen Textobjekten die PortionInfos merken: +/*N*/ // Schwelle rauf setzen, wenn Olli die Absaetze nicht mehr zerhackt! +/*N*/ if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) ) +/*N*/ { +/*?*/ XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), aPaperSize.Width() ); +/*?*/ pTxtObj->SetPortionInfo( pXList ); +/*?*/ for ( nNode = nStartNode; nNode <= nEndNode; nNode++ ) +/*?*/ { +/*?*/ ParaPortion* pParaPortion = GetParaPortions()[nNode]; +/*?*/ XParaPortion* pX = new XParaPortion; +/*?*/ pXList->Insert( pX, pXList->Count() ); +/*?*/ +/*?*/ pX->nHeight = pParaPortion->GetHeight(); +/*?*/ pX->nFirstLineOffset = pParaPortion->GetFirstLineOffset(); +/*?*/ +/*?*/ // Die TextPortions +/*?*/ sal_uInt16 nCount = pParaPortion->GetTextPortions().Count(); +/*?*/ sal_uInt16 n; +/*?*/ for ( n = 0; n < nCount; n++ ) +/*?*/ { +/*?*/ TextPortion* pTextPortion = pParaPortion->GetTextPortions()[n]; +/*?*/ TextPortion* pNew = new TextPortion( *pTextPortion ); +/*?*/ pX->aTextPortions.Insert( pNew, pX->aTextPortions.Count() ); +/*?*/ } +/*?*/ +/*?*/ // Die Zeilen +/*?*/ nCount = pParaPortion->GetLines().Count(); +/*?*/ for ( n = 0; n < nCount; n++ ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditLine* pLine = pParaPortion->GetLines()[n]; +/*?*/ } +/*?*/ #ifdef DBG_UTIL +/*?*/ USHORT nTest, nTPLen = 0, nTxtLen = 0; +/*?*/ for ( nTest = pParaPortion->GetTextPortions().Count(); nTest; ) +/*?*/ nTPLen += pParaPortion->GetTextPortions().GetObject( --nTest )->GetLen(); +/*?*/ for ( nTest = pParaPortion->GetLines().Count(); nTest; ) +/*?*/ nTxtLen += pParaPortion->GetLines().GetObject( --nTest )->GetLen(); +/*?*/ DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "CreateBinTextObject: ParaPortion not completely formatted!" ); +/*?*/ #endif +/*?*/ } +/*N*/ } +/*N*/ return pTxtObj; +/*N*/ } + +/*N*/ void ImpEditEngine::SetText( const EditTextObject& rTextObject ) +/*N*/ { +/*N*/ // Da Setzen eines TextObject ist nicht Undo-faehig! +/*N*/ ResetUndoManager(); +/*N*/ sal_Bool bUpdate = GetUpdateMode(); +/*N*/ sal_Bool bUndo = IsUndoEnabled(); +/*N*/ +/*N*/ SetText( XubString() ); +/*N*/ EditPaM aPaM = aEditDoc.GetStartPaM(); +/*N*/ +/*N*/ SetUpdateMode( sal_False ); +/*N*/ EnableUndo( sal_False ); +/*N*/ +/*N*/ InsertText( rTextObject, EditSelection( aPaM, aPaM ) ); +/*N*/ SetVertical( rTextObject.IsVertical() ); +/*N*/ +/*N*/ #ifndef SVX_LIGHT +/*N*/ DBG_ASSERT( !HasUndoManager() || !GetUndoManager().GetUndoActionCount(), "Woher kommt das Undo in SetText ?!" ); +/*N*/ #endif +/*N*/ SetUpdateMode( bUpdate ); +/*N*/ EnableUndo( bUndo ); +/*N*/ } + +/*N*/ EditSelection ImpEditEngine::InsertText( const EditTextObject& rTextObject, EditSelection aSel ) +/*N*/ { +/*N*/ EnterBlockNotifications(); +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ if ( aSel.HasRange() ) +/*?*/ aSel = ImpDeleteSelection( aSel ); +/*N*/ EditSelection aNewSel = InsertBinTextObject( (BinTextObject&)rTextObject, aSel.Max() ); +/*N*/ LeaveBlockNotifications(); +/*N*/ return aNewSel; +/*N*/ +/*N*/ // MT 05/00: InsertBinTextObject direkt hier machen... +/*N*/ } + +/*N*/ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, EditPaM aPaM ) +/*N*/ { +/*N*/ // Optimieren: +/*N*/ // Kein GetPos undFindParaportion, sondern Index berechnen! +/*N*/ EditSelection aSel( aPaM, aPaM ); +/*N*/ +/*N*/ sal_Bool bUsePortionInfo = sal_False; +/*N*/ sal_Bool bFields = sal_False; +/*N*/ XParaPortionList* pPortionInfo = rTextObject.GetPortionInfo(); +/*N*/ +/*N*/ if ( pPortionInfo && ( (long)pPortionInfo->GetPaperWidth() == aPaperSize.Width() ) +/*N*/ && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() ) ) +/*N*/ { +/*?*/ if ( ( pPortionInfo->GetRefDevPtr() == (sal_uIntPtr)GetRefDevice() ) || +/*?*/ ( ( pPortionInfo->GetRefDevType() == OUTDEV_VIRDEV ) && +/*?*/ ( GetRefDevice()->GetOutDevType() == OUTDEV_VIRDEV ) ) ) +/*?*/ bUsePortionInfo = sal_True; +/*N*/ } +/*N*/ +/*N*/ sal_Bool bConvertItems = sal_False; +/*N*/ MapUnit eSourceUnit, eDestUnit; +/*N*/ if ( rTextObject.HasMetric() ) +/*N*/ { +/*N*/ eSourceUnit = (MapUnit)rTextObject.GetMetric(); +/*N*/ eDestUnit = (MapUnit)aEditDoc.GetItemPool().GetMetric( DEF_METRIC ); +/*N*/ if ( eSourceUnit != eDestUnit ) +/*N*/ bConvertItems = sal_True; +/*N*/ } +/*N*/ +/*N*/ sal_uInt16 nContents = rTextObject.GetContents().Count(); +/*N*/ sal_uInt16 nPara = aEditDoc.GetPos( aPaM.GetNode() ); +/*N*/ +/*N*/ for ( sal_uInt16 n = 0; n < nContents; n++, nPara++ ) +/*N*/ { +/*N*/ ContentInfo* pC = rTextObject.GetContents().GetObject( n ); +/*N*/ sal_Bool bNewContent = aPaM.GetNode()->Len() ? sal_False: sal_True; +/*N*/ sal_uInt16 nStartPos = aPaM.GetIndex(); +/*N*/ +/*N*/ aPaM = ImpFastInsertText( aPaM, pC->GetText() ); +/*N*/ +/*N*/ ParaPortion* pPortion = FindParaPortion( aPaM.GetNode() ); +/*N*/ DBG_ASSERT( pPortion, "Blinde Portion in FastInsertText" ); +/*N*/ pPortion->MarkInvalid( nStartPos, pC->GetText().Len() ); +/*N*/ +/*N*/ // Zeicheattribute... +/*N*/ sal_Bool bAllreadyHasAttribs = aPaM.GetNode()->GetCharAttribs().Count() ? sal_True : sal_False; +/*N*/ sal_uInt16 nNewAttribs = pC->GetAttribs().Count(); +/*N*/ if ( nNewAttribs ) +/*N*/ { +/*N*/ BOOL bUpdateFields = FALSE; +/*N*/ for ( sal_uInt16 nAttr = 0; nAttr < nNewAttribs; nAttr++ ) +/*N*/ { +/*N*/ XEditAttribute* pX = pC->GetAttribs().GetObject( nAttr ); +/*N*/ // Kann passieren wenn Absaetze >16K entstehen, dann wird einfach umgebrochen. +/*N*/ if ( pX->GetEnd() <= aPaM.GetNode()->Len() ) +/*N*/ { +/*N*/ if ( !bAllreadyHasAttribs || pX->IsFeature() ) +/*N*/ { +/*N*/ // Normale Attribute gehen dann schneller... +/*N*/ // Features duerfen nicht ueber EditDoc::InsertAttrib +/*N*/ // eingefuegt werden, sie sind bei FastInsertText schon im TextFluss +/*N*/ DBG_ASSERT( pX->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribut zu gross!" ); +/*N*/ EditCharAttrib* pAttr; +/*N*/ if ( !bConvertItems ) +/*N*/ pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(pX->GetItem()), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos ); +/*N*/ else +/*N*/ { +/*?*/ SfxPoolItem* pNew = pX->GetItem()->Clone(); +/*?*/ ConvertItem( *pNew, eSourceUnit, eDestUnit ); +/*?*/ pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos ); +/*?*/ delete pNew; +/*N*/ } +/*N*/ DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribut passt nicht! (1)" ); +/*N*/ aPaM.GetNode()->GetCharAttribs().InsertAttrib( pAttr ); +/*N*/ if ( pAttr->Which() == EE_FEATURE_FIELD ) +/*N*/ bUpdateFields = TRUE; +/*N*/ } +/*N*/ else +/*N*/ { +/*?*/ DBG_ASSERT( pX->GetEnd()+nStartPos <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribut passt nicht! (2)" ); +/*?*/ // Tabs und andere Features koennen nicht ueber InsertAttrib eingefuegt werden: +/*?*/ aEditDoc.InsertAttrib( aPaM.GetNode(), pX->GetStart()+nStartPos, pX->GetEnd()+nStartPos, *pX->GetItem() ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if ( bUpdateFields ) +/*N*/ UpdateFields(); +/*N*/ +/*N*/ // Sonst QuickFormat => Keine Attribute! +/*N*/ pPortion->MarkSelectionInvalid( nStartPos, pC->GetText().Len() ); +/*N*/ } +/*N*/ +/*N*/ DBG_ASSERT( CheckOrderedList( aPaM.GetNode()->GetCharAttribs().GetAttribs(), sal_True ), "InsertBinTextObject: Start-Liste verdreht" ); +/*N*/ +/*N*/ sal_Bool bParaAttribs = sal_False; +/*N*/ if ( bNewContent || ( ( n > 0 ) && ( n < (nContents-1) ) ) ) +/*N*/ { +/*N*/ bParaAttribs = sal_False; +/*N*/ // #101512# Don't overwrite level/style from existing paragraph in OutlineView +/*N*/ // MT 10/2002: Removed because of #103874#, handled in Outliner::EndPasteOrDropHdl now. +/*N*/ // if ( !aStatus.IsOutliner() || n ) +/*N*/ { +/*N*/ // nur dann Style und ParaAttribs, wenn neuer Absatz, oder +/*N*/ // komplett inneliegender... +/*N*/ bParaAttribs = pC->GetParaAttribs().Count() ? sal_True : sal_False; +/*N*/ if ( GetStyleSheetPool() && pC->GetStyle().Len() ) +/*N*/ { +/*N*/ SfxStyleSheet* pStyle = (SfxStyleSheet*)GetStyleSheetPool()->Find( pC->GetStyle(), pC->GetFamily() ); +/*N*/ DBG_ASSERT( pStyle, "InsertBinTextObject - Style not found!" ); +/*N*/ SetStyleSheet( nPara, pStyle ); +/*N*/ } +/*N*/ if ( !bConvertItems ) +/*N*/ SetParaAttribs( aEditDoc.GetPos( aPaM.GetNode() ), pC->GetParaAttribs() ); +/*N*/ else +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } +/*N*/ } +/*N*/ if ( bNewContent && bUsePortionInfo ) +/*N*/ { +/*?*/ XParaPortion* pXP = pPortionInfo->GetObject( n ); +/*?*/ DBG_ASSERT( pXP, "InsertBinTextObject: PortionInfo?" ); +/*?*/ ParaPortion* pParaPortion = GetParaPortions()[ nPara ]; +/*?*/ DBG_ASSERT( pParaPortion, "InsertBinTextObject: ParaPortion?" ); +/*?*/ pParaPortion->nHeight = pXP->nHeight; +/*?*/ pParaPortion->nFirstLineOffset = pXP->nFirstLineOffset; +/*?*/ pParaPortion->bForceRepaint = sal_True; +/*?*/ pParaPortion->SetValid(); // Nicht formatieren +/*?*/ +/*?*/ // Die TextPortions +/*?*/ pParaPortion->GetTextPortions().Reset(); +/*?*/ sal_uInt16 nCount = pXP->aTextPortions.Count(); +/*?*/ for ( sal_uInt16 n = 0; n < nCount; n++ ) +/*?*/ { +/*?*/ TextPortion* pTextPortion = pXP->aTextPortions[n]; +/*?*/ TextPortion* pNew = new TextPortion( *pTextPortion ); +/*?*/ pParaPortion->GetTextPortions().Insert( pNew, n ); +/*?*/ } +/*?*/ +/*?*/ // Die Zeilen +/*?*/ pParaPortion->GetLines().Reset(); +/*?*/ nCount = pXP->aLines.Count(); +/*?*/ for ( sal_uInt16 m = 0; m < nCount; m++ ) +/*?*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditLine* pLine = pXP->aLines[m]; +/*?*/ } +/*?*/ #ifdef DBG_UTIL +/*?*/ USHORT nTest, nTPLen = 0, nTxtLen = 0; +/*?*/ for ( nTest = pParaPortion->GetTextPortions().Count(); nTest; ) +/*?*/ nTPLen += pParaPortion->GetTextPortions().GetObject( --nTest )->GetLen(); +/*?*/ for ( nTest = pParaPortion->GetLines().Count(); nTest; ) +/*?*/ nTxtLen += pParaPortion->GetLines().GetObject( --nTest )->GetLen(); +/*?*/ DBG_ASSERT( ( nTPLen == pParaPortion->GetNode()->Len() ) && ( nTxtLen == pParaPortion->GetNode()->Len() ), "InsertBinTextObject: ParaPortion not completely formatted!" ); +/*?*/ #endif +/*N*/ } +/*N*/ } +/*N*/ if ( !bParaAttribs ) // DefFont wird bei FastInsertParagraph nicht berechnet +/*N*/ { +/*N*/ aPaM.GetNode()->GetCharAttribs().GetDefFont() = aEditDoc.GetDefFont(); +/*N*/ if ( aStatus.UseCharAttribs() ) +/*N*/ aPaM.GetNode()->CreateDefFont(); +/*N*/ } +/*N*/ +/*N*/ // Zeilenumbruch, wenn weitere folgen... +/*N*/ if ( n < ( nContents-1) ) +/*N*/ { +/*N*/ if ( bNewContent ) +/*N*/ aPaM = ImpFastInsertParagraph( nPara+1 ); +/*N*/ else +/*?*/ aPaM = ImpInsertParaBreak( aPaM, sal_False ); +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ aSel.Max() = aPaM; +/*N*/ return aSel; +/*N*/ } + +/*N*/ LanguageType ImpEditEngine::GetLanguage( const EditPaM& rPaM, USHORT* pEndPos ) const +/*N*/ { +/*N*/ short nScriptType = GetScriptType( rPaM, pEndPos ); // pEndPos will be valid now, pointing to ScriptChange or NodeLen +/*N*/ USHORT nLangId = GetScriptItemId( EE_CHAR_LANGUAGE, nScriptType ); +/*N*/ const SvxLanguageItem* pLangItem = &(const SvxLanguageItem&)rPaM.GetNode()->GetContentAttribs().GetItem( nLangId ); +/*N*/ EditCharAttrib* pAttr = rPaM.GetNode()->GetCharAttribs().FindAttrib( nLangId, rPaM.GetIndex() ); +/*N*/ if ( pAttr ) +/*?*/ pLangItem = (const SvxLanguageItem*)pAttr->GetItem(); +/*N*/ +/*N*/ if ( pEndPos && pAttr && ( pAttr->GetEnd() < *pEndPos ) ) +/*?*/ *pEndPos = pAttr->GetEnd(); +/*N*/ +/*N*/ return pLangItem->GetLanguage(); +/*N*/ } + +/*N*/ ::com::sun::star::lang::Locale ImpEditEngine::GetLocale( const EditPaM& rPaM ) const +/*N*/ { +/*N*/ return SvxCreateLocale( GetLanguage( rPaM ) ); +/*N*/ } + + + + + + + + + + + + + + +/*N*/ void ImpEditEngine::SetAsianCompressionMode( USHORT n ) +/*N*/ { +/*N*/ if ( n != nAsianCompressionMode ) +/*N*/ { +/*N*/ nAsianCompressionMode = n; +/*N*/ if ( ImplHasText() ) +/*N*/ { +/*N*/ FormatFullDoc(); +/*N*/ UpdateViews(); +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void ImpEditEngine::SetKernAsianPunctuation( BOOL b ) +/*N*/ { +/*N*/ if ( b != bKernAsianPunctuation ) +/*N*/ { +/*NBFF*/ bKernAsianPunctuation = b; +/*NBFF*/ if ( ImplHasText() ) +/*NBFF*/ { +/*NBFF*/ FormatFullDoc(); +/*NBFF*/ UpdateViews(); +/*NBFF*/ } +/*N*/ } +/*N*/ } + + +/*N*/ BOOL ImpEditEngine::ImplHasText() const +/*N*/ { +/*N*/ return ( ( GetEditDoc().Count() > 1 ) || GetEditDoc().GetObject(0)->Len() ); +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_impedit5.cxx b/binfilter/bf_svx/source/editeng/svx_impedit5.cxx new file mode 100644 index 000000000000..7fb359d9e175 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_impedit5.cxx @@ -0,0 +1,566 @@ +/* -*- 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. + * + ************************************************************************/ + + +#ifdef _MSC_VER +#pragma hdrstop +#endif + + + +#include <vcl/window.hxx> + +#include <impedit.hxx> +#include <editeng.hxx> + + + +namespace binfilter { + +/*N*/ void ImpEditEngine::SetStyleSheetPool( SfxStyleSheetPool* pSPool ) +/*N*/ { +/*N*/ if ( pStylePool != pSPool ) +/*N*/ { +/*N*/ // if ( pStylePool ) +/*N*/ // EndListening( *pStylePool, TRUE ); +/*N*/ +/*N*/ pStylePool = pSPool; +/*N*/ +/*N*/ // if ( pStylePool ) +/*N*/ // StartListening( *pStylePool, TRUE ); +/*N*/ } +/*N*/ } + +/*N*/ SfxStyleSheet* ImpEditEngine::GetStyleSheet( USHORT nPara ) const +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ return pNode ? pNode->GetContentAttribs().GetStyleSheet() : NULL; +/*N*/ } + +/*N*/ void ImpEditEngine::SetStyleSheet( USHORT nPara, SfxStyleSheet* pStyle ) +/*N*/ { +/*N*/ DBG_ASSERT( GetStyleSheetPool() || !pStyle, "SetStyleSheet: No StyleSheetPool registered!" ); +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ SfxStyleSheet* pCurStyle = pNode->GetStyleSheet(); +/*N*/ if ( pStyle != pCurStyle ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) +/*N*/ { +/*N*/ XubString aPrevStyleName; +/*N*/ if ( pCurStyle ) +/*N*/ aPrevStyleName = pCurStyle->GetName(); +/*N*/ +/*N*/ XubString aNewStyleName; +/*N*/ if ( pStyle ) +/*N*/ aNewStyleName = pStyle->GetName(); +/*N*/ +/*N*/ InsertUndo( +/*N*/ new EditUndoSetStyleSheet( this, aEditDoc.GetPos( pNode ), +/*N*/ aPrevStyleName, pCurStyle ? pCurStyle->GetFamily() : SFX_STYLE_FAMILY_PARA, +/*N*/ aNewStyleName, pStyle ? pStyle->GetFamily() : SFX_STYLE_FAMILY_PARA, +/*N*/ pNode->GetContentAttribs().GetItems() ) ); +/*N*/ } +/*N*/ #endif +/*N*/ if ( pCurStyle ) +/*N*/ EndListening( *pCurStyle, FALSE ); +/*N*/ pNode->SetStyleSheet( pStyle, aStatus.UseCharAttribs() ); +/*N*/ if ( pStyle ) +/*N*/ StartListening( *pStyle, FALSE ); +/*N*/ ParaAttribsChanged( pNode ); +/*N*/ } +/*N*/ FormatAndUpdate(); +/*N*/ } + + + + + + +/*N*/ void ImpEditEngine::UndoActionStart( USHORT nId ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*N*/ { +/*N*/ GetUndoManager().EnterListAction( GetEditEnginePtr()->GetUndoComment( nId ), XubString(), nId ); +/*N*/ DBG_ASSERT( !pUndoMarkSelection, "UndoAction SelectionMarker?" ); +/*N*/ } +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::UndoActionEnd( USHORT nId ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() ) +/*N*/ { +/*N*/ GetUndoManager().LeaveListAction(); +/*N*/ delete pUndoMarkSelection; +/*N*/ pUndoMarkSelection = NULL; +/*N*/ } +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::InsertUndo( EditUndo* pUndo, BOOL bTryMerge ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ DBG_ASSERT( !IsInUndo(), "InsertUndo im Undomodus!" ); +/*N*/ if ( pUndoMarkSelection ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 EditUndoMarkSelection* pU = new EditUndoMarkSelection( this, *pUndoMarkSelection ); +/*N*/ } +/*N*/ GetUndoManager().AddUndoAction( pUndo, bTryMerge ); +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::ResetUndoManager() +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( HasUndoManager() ) +/*N*/ GetUndoManager().Clear(); +/*N*/ #endif +/*N*/ } + +/*N*/ void ImpEditEngine::EnableUndo( BOOL bEnable ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ // Beim Umschalten des Modus Liste loeschen: +/*N*/ if ( bEnable != IsUndoEnabled() ) +/*N*/ ResetUndoManager(); +/*N*/ +/*N*/ bUndoEnabled = bEnable; +/*N*/ #endif +/*N*/ } + + + + +/*N*/ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, BOOL bOnlyHardAttrib ) +/*N*/ { +/*N*/ DBG_CHKOBJ( GetEditEnginePtr(), EditEngine, 0 ); +/*N*/ +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ +/*N*/ #if OSL_DEBUG_LEVEL > 1 +/*N*/ // if ( ( aSel.Min().GetNode() == aSel.Max().GetNode() ) && ( bOnlyHardAttrib == EditEngineAttribs_All ) ) +/*N*/ // return GetAttribs( aEditDoc.GetPos( aSel.Min().GetNode() ), aSel.Min().GetIndex(), aSel.Max().GetIndex(), GETATTRIBS_ALL ); +/*N*/ #endif +/*N*/ +/*N*/ +/*N*/ SfxItemSet aCurSet( GetEmptyItemSet() ); +/*N*/ +/*N*/ USHORT nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); +/*N*/ USHORT nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); +/*N*/ +/*N*/ // ueber die Absaetze iterieren... +/*N*/ for ( USHORT nNode = nStartNode; nNode <= nEndNode; nNode++ ) +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nNode ); +/*N*/ DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node nicht gefunden: GetAttrib" ); +/*N*/ +/*N*/ xub_StrLen nStartPos = 0; +/*N*/ xub_StrLen nEndPos = pNode->Len(); +/*N*/ if ( nNode == nStartNode ) +/*N*/ nStartPos = aSel.Min().GetIndex(); +/*N*/ if ( nNode == nEndNode ) // kann auch == nStart sein! +/*N*/ nEndPos = aSel.Max().GetIndex(); +/*N*/ +/*N*/ // Problem: Vorlagen.... +/*N*/ // => Andersrum: +/*N*/ // 1) Harte Zeichenattribute, wie gehabt... +/*N*/ // 2) Nur wenn OFF, Style and Absatzattr. pruefen... +/*N*/ +/*N*/ // Erst die ganz harte Formatierung... +/*N*/ aEditDoc.FindAttribs( pNode, nStartPos, nEndPos, aCurSet ); +/*N*/ +/*N*/ if( bOnlyHardAttrib != EditEngineAttribs_OnlyHard ) +/*N*/ { +/*N*/ // Und dann Absatzformatierung und Vorlage... +/*N*/ // SfxStyleSheet* pStyle = pNode->GetStyleSheet(); +/*N*/ for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_CHAR_END; nWhich++) +/*N*/ { +/*N*/ if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) +/*N*/ { +/*N*/ if ( bOnlyHardAttrib == EditEngineAttribs_All ) +/*N*/ { +/*N*/ const SfxPoolItem& rItem = pNode->GetContentAttribs().GetItem( nWhich ); +/*N*/ aCurSet.Put( rItem ); +/*N*/ } +/*N*/ else if ( pNode->GetContentAttribs().GetItems().GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ const SfxPoolItem& rItem = pNode->GetContentAttribs().GetItems().Get( nWhich ); +/*?*/ aCurSet.Put( rItem ); +/*N*/ } +/*N*/ } +/*N*/ else if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SfxPoolItem* pItem = NULL; +/*N*/ if ( bOnlyHardAttrib == EditEngineAttribs_All ) +/*N*/ { +/*N*/ pItem = &pNode->GetContentAttribs().GetItem( nWhich ); +/*N*/ } +/*N*/ else if ( pNode->GetContentAttribs().GetItems().GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*?*/ pItem = &pNode->GetContentAttribs().GetItems().Get( nWhich ); +/*N*/ } +/*N*/ // pItem can only be NULL when bOnlyHardAttrib... +/*N*/ if ( !pItem || ( *pItem != aCurSet.Get( nWhich ) ) ) +/*N*/ { +/*N*/ // Problem: Wenn Absatzvorlage mit z.B. Font, +/*N*/ // aber Font hart und anders und komplett in Selektion +/*N*/ // Falsch, wenn invalidiert.... +/*N*/ // => Lieber nicht invalidieren, UMSTELLEN! +/*N*/ // Besser waere, Absatzweise ein ItemSet zu fuellen +/*N*/ // und dieses mit dem gesmten vergleichen. +/*N*/ // aCurSet.InvalidateItem( nWhich ); +/*N*/ if ( nWhich <= EE_PARA_END ) +/*?*/ aCurSet.InvalidateItem( nWhich ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ // Leere Slots mit Defaults fuellen... +/*N*/ if ( bOnlyHardAttrib == EditEngineAttribs_All ) +/*N*/ { +/*N*/ for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_CHAR_END; nWhich++ ) +/*N*/ { +/*N*/ if ( aCurSet.GetItemState( nWhich ) == SFX_ITEM_OFF ) +/*N*/ { +/*?*/ aCurSet.Put( aEditDoc.GetItemPool().GetDefaultItem( nWhich ) ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ /* +/*N*/ #ifdef MAC +/*N*/ FILE* fp = fopen( "debug.log", "a" ); +/*N*/ #elif defined UNX +/*N*/ FILE* fp = fopen( "/tmp/debug.log", "a" ); +/*N*/ #else +/*N*/ FILE* fp = fopen( "d:\\debug.log", "a" ); +/*N*/ #endif +/*N*/ if ( fp ) +/*N*/ { +/*N*/ fprintf( fp, "\n\n<= Attribute: Absatz %i\n", nNode ); +/*N*/ DbgOutItemSet( fp, aCurSet, TRUE, FALSE ); +/*N*/ fclose( fp ); +/*N*/ } +/*N*/ */ +/*N*/ #endif +/*N*/ +/*N*/ return aCurSet; +/*N*/ } + + +/*N*/ SfxItemSet ImpEditEngine::GetAttribs( USHORT nPara, USHORT nStart, USHORT nEnd, sal_uInt8 nFlags ) const +/*N*/ { +/*N*/ // MT: #94002# Optimized function with less Puts(), which cause unnecessary cloning from default items. +/*N*/ // If this works, change GetAttribs( EditSelection ) to use this for each paragraph and merge the results! +/*N*/ +/*N*/ DBG_CHKOBJ( GetEditEnginePtr(), EditEngine, 0 ); +/*N*/ +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "GetAttribs - unknown paragraph!" ); +/*N*/ DBG_ASSERT( nStart <= nEnd, "getAttribs: Start > End not supported!" ); +/*N*/ +/*N*/ SfxItemSet aAttribs( ((ImpEditEngine*)this)->GetEmptyItemSet() ); +/*N*/ +/*N*/ if ( pNode ) +/*N*/ { +/*N*/ if ( nEnd > pNode->Len() ) +/*N*/ nEnd = pNode->Len(); +/*?*/ +/*N*/ if ( nStart > nEnd ) +/*?*/ nStart = nEnd; +/*N*/ +/*N*/ // StyleSheet / Parattribs... +/*N*/ +/*N*/ if ( pNode->GetStyleSheet() && ( nFlags & GETATTRIBS_STYLESHEET ) ) +/*N*/ aAttribs.Set( pNode->GetStyleSheet()->GetItemSet(), TRUE ); +/*N*/ +/*N*/ if ( nFlags & GETATTRIBS_PARAATTRIBS ) +/*N*/ aAttribs.Put( pNode->GetContentAttribs().GetItems() ); +/*N*/ +/*N*/ // CharAttribs... +/*N*/ +/*N*/ if ( nFlags & GETATTRIBS_CHARATTRIBS ) +/*N*/ { +/*N*/ // Make testing easier... +/*N*/ pNode->GetCharAttribs().OptimizeRanges( ((ImpEditEngine*)this)->GetEditDoc().GetItemPool() ); +/*N*/ +/*N*/ const CharAttribArray& rAttrs = pNode->GetCharAttribs().GetAttribs(); +/*N*/ for ( USHORT nAttr = 0; nAttr < rAttrs.Count(); nAttr++ ) +/*N*/ { +/*N*/ EditCharAttrib* pAttr = rAttrs.GetObject( nAttr ); +/*N*/ +/*N*/ if ( nStart == nEnd ) +/*N*/ { +/*N*/ USHORT nCursorPos = nStart; +/*N*/ if ( ( pAttr->GetStart() <= nCursorPos ) && ( pAttr->GetEnd() >= nCursorPos ) ) +/*N*/ { +/*N*/ // To be used the attribute has to start BEFORE the position, or it must be a +/*N*/ // new empty attr AT the position, or we are on position 0. +/*N*/ if ( ( pAttr->GetStart() < nCursorPos ) || pAttr->IsEmpty() || !nCursorPos ) +/*N*/ { +/*N*/ // maybe this attrib ends here and a new attrib with 0 Len may follow and be valid here, +/*N*/ // but that s no problem, the empty item will come later and win. +/*N*/ aAttribs.Put( *pAttr->GetItem() ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Check every attribute covering the area, partial or full. +/*N*/ if ( ( pAttr->GetStart() < nEnd ) && ( pAttr->GetEnd() > nStart ) ) +/*N*/ { +/*N*/ if ( ( pAttr->GetStart() <= nStart ) && ( pAttr->GetEnd() >= nEnd ) ) +/*N*/ { +/*N*/ // full coverage +/*N*/ aAttribs.Put( *pAttr->GetItem() ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // OptimizeRagnge() assures that not the same attr can follow for full coverage +/*N*/ // only partial, check with current, when using para/styhe, otherwise invalid. +/*N*/ if ( !( nFlags & (GETATTRIBS_PARAATTRIBS|GETATTRIBS_STYLESHEET) ) || +/*N*/ ( *pAttr->GetItem() != aAttribs.Get( pAttr->Which() ) ) ) +/*N*/ { +/*N*/ aAttribs.InvalidateItem( pAttr->Which() ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( pAttr->GetStart() > nEnd ) +/*N*/ { +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ return aAttribs; +/*N*/ } + + +/*N*/ void ImpEditEngine::SetAttribs( EditSelection aSel, const SfxItemSet& rSet, BYTE nSpecial ) +/*N*/ { +/*N*/ aSel.Adjust( aEditDoc ); +/*N*/ +/*N*/ // Wenn keine Selektion => die Attribute aufs Wort anwenden. +/*N*/ // ( Der RTF-Perser sollte die Methode eigentlich nie ohne Range rufen ) +/*N*/ if ( ( nSpecial == ATTRSPECIAL_WHOLEWORD ) && !aSel.HasRange() ) +/*?*/ aSel = SelectWord( aSel, ::com::sun::star::i18n::WordType::ANYWORD_IGNOREWHITESPACES, FALSE ); +/*N*/ +/*N*/ USHORT nStartNode = aEditDoc.GetPos( aSel.Min().GetNode() ); +/*N*/ USHORT nEndNode = aEditDoc.GetPos( aSel.Max().GetNode() ); +/*N*/ +/*N*/ BOOL bCheckLanguage = FALSE; +/*N*/ +/*N*/ // ueber die Absaetze iterieren... +/*N*/ for ( USHORT nNode = nStartNode; nNode <= nEndNode; nNode++ ) +/*N*/ { +/*N*/ BOOL bParaAttribFound = FALSE; +/*N*/ BOOL bCharAttribFound = FALSE; +/*N*/ +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nNode ); +/*N*/ ParaPortion* pPortion = GetParaPortions().GetObject( nNode ); +/*N*/ +/*N*/ DBG_ASSERT( aEditDoc.SaveGetObject( nNode ), "Node nicht gefunden: SetAttribs" ); +/*N*/ DBG_ASSERT( GetParaPortions().GetObject( nNode ), "Portion nicht gefunden: SetAttribs" ); +/*N*/ +/*N*/ xub_StrLen nStartPos = 0; +/*N*/ xub_StrLen nEndPos = pNode->Len(); +/*N*/ if ( nNode == nStartNode ) +/*N*/ nStartPos = aSel.Min().GetIndex(); +/*N*/ if ( nNode == nEndNode ) // kann auch == nStart sein! +/*N*/ nEndPos = aSel.Max().GetIndex(); +/*N*/ +/*N*/ // ueber die Items iterieren... +/*N*/ #ifdef EDITDEBUG +/*N*/ // FILE* fp = fopen( "d:\\debug.log", "a" ); +/*N*/ // if ( fp ) +/*N*/ // { +/*N*/ // fprintf( fp, "\n\n=> Zeichen-Attribute: Absatz %i, %i-%i\n", nNode, nStartPos, nEndPos ); +/*N*/ // DbgOutItemSet( fp, rSet, TRUE, FALSE ); +/*N*/ // fclose( fp ); +/*N*/ // } +/*N*/ #endif +/*N*/ +/*N*/ for ( USHORT nWhich = EE_ITEMS_START; nWhich <= EE_CHAR_END; nWhich++) +/*N*/ { +/*N*/ if ( rSet.GetItemState( nWhich ) == SFX_ITEM_ON ) +/*N*/ { +/*N*/ const SfxPoolItem& rItem = rSet.Get( nWhich ); +/*N*/ if ( nWhich <= EE_PARA_END ) +/*N*/ { +/*?*/ pNode->GetContentAttribs().GetItems().Put( rItem ); +/*?*/ bParaAttribFound = TRUE; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ aEditDoc.InsertAttrib( pNode, nStartPos, nEndPos, rItem ); +/*N*/ bCharAttribFound = TRUE; +/*N*/ if ( nSpecial == ATTRSPECIAL_EDGE ) +/*N*/ { +/*?*/ CharAttribArray& rAttribs = pNode->GetCharAttribs().GetAttribs(); +/*?*/ USHORT nAttrs = rAttribs.Count(); +/*?*/ for ( USHORT n = 0; n < nAttrs; n++ ) +/*?*/ { +/*?*/ EditCharAttrib* pAttr = rAttribs.GetObject( n ); +/*?*/ if ( pAttr->GetStart() > nEndPos ) +/*?*/ break; +/*?*/ +/*?*/ if ( ( pAttr->GetEnd() == nEndPos ) && ( pAttr->Which() == nWhich ) ) +/*?*/ { +/*?*/ pAttr->SetEdge( TRUE ); +/*?*/ break; +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ +/*N*/ if ( bParaAttribFound ) +/*N*/ { +/*?*/ ParaAttribsChanged( pPortion->GetNode() ); +/*N*/ } +/*N*/ else if ( bCharAttribFound ) +/*N*/ { +/*N*/ bFormatted = FALSE; +/*N*/ if ( !pNode->Len() || ( nStartPos != nEndPos ) ) +/*N*/ { +/*N*/ pPortion->MarkSelectionInvalid( nStartPos, nEndPos-nStartPos ); +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ typedef EditCharAttrib* EditCharAttribPtr; + +/*N*/ void ImpEditEngine::RemoveCharAttribs( USHORT nPara, USHORT nWhich, BOOL bRemoveFeatures ) +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ ParaPortion* pPortion = GetParaPortions().SaveGetObject( nPara ); +/*N*/ +/*N*/ DBG_ASSERT( pNode, "Node nicht gefunden: RemoveCharAttribs" ); +/*N*/ DBG_ASSERT( pPortion, "Portion nicht gefunden: RemoveCharAttribs" ); +/*N*/ +/*N*/ if ( !pNode ) +/*N*/ return; +/*N*/ +/*N*/ USHORT nAttr = 0; +/*N*/ EditCharAttribPtr pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ while ( pAttr ) +/*N*/ { +/*N*/ if ( ( !pAttr->IsFeature() || bRemoveFeatures ) && +/*N*/ ( !nWhich || ( pAttr->GetItem()->Which() == nWhich ) ) ) +/*N*/ { +/*?*/ pNode->GetCharAttribs().GetAttribs().Remove( nAttr ); +/*?*/ delete pAttr; +/*?*/ nAttr--; +/*N*/ } +/*N*/ nAttr++; +/*N*/ pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr ); +/*N*/ } +/*N*/ +/*N*/ pPortion->MarkSelectionInvalid( 0, pNode->Len() ); +/*N*/ } + +/*N*/ void ImpEditEngine::SetParaAttribs( USHORT nPara, const SfxItemSet& rSet ) +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.SaveGetObject( nPara ); +/*N*/ +/*N*/ if ( !pNode ) +/*N*/ return; +/*N*/ +/*N*/ #ifdef EDITDEBUG +/*N*/ // FILE* fp = fopen( "d:\\debug.log", "a" ); +/*N*/ // if ( fp ) +/*N*/ // { +/*N*/ // fprintf( fp, "\n\n=> Absatz-Attribute: Absatz %i\n", nPara ); +/*N*/ // DbgOutItemSet( fp, rSet, TRUE, FALSE ); +/*N*/ // fclose( fp ); +/*N*/ // } +/*N*/ #endif +/*N*/ +/*N*/ if ( !( pNode->GetContentAttribs().GetItems() == rSet ) ) +/*N*/ { +/*N*/ #ifndef SVX_LIGHT +/*N*/ if ( IsUndoEnabled() && !IsInUndo() && aStatus.DoUndoAttribs() ) +/*N*/ { +/*N*/ if ( rSet.GetPool() != &aEditDoc.GetItemPool() ) +/*N*/ { +/*?*/ SfxItemSet aTmpSet( GetEmptyItemSet() ); +/*?*/ aTmpSet.Put( rSet ); +/*?*/ InsertUndo( new EditUndoSetParaAttribs( this, nPara, pNode->GetContentAttribs().GetItems(), aTmpSet ) ); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ InsertUndo( new EditUndoSetParaAttribs( this, nPara, pNode->GetContentAttribs().GetItems(), rSet ) ); +/*N*/ } +/*N*/ } +/*N*/ #endif +/*N*/ pNode->GetContentAttribs().GetItems().Set( rSet ); +/*N*/ if ( aStatus.UseCharAttribs() ) +/*N*/ pNode->CreateDefFont(); +/*N*/ +/*N*/ ParaAttribsChanged( pNode ); +/*N*/ } +/*N*/ } + +/*N*/ const SfxItemSet& ImpEditEngine::GetParaAttribs( USHORT nPara ) const +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "Node nicht gefunden: GetParaAttribs" ); +/*N*/ return pNode->GetContentAttribs().GetItems(); +/*N*/ } + +/*N*/ BOOL ImpEditEngine::HasParaAttrib( USHORT nPara, USHORT nWhich ) const +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "Node nicht gefunden: HasParaAttrib" ); +/*N*/ +/*N*/ return pNode->GetContentAttribs().HasItem( nWhich ); +/*N*/ } + +/*N*/ const SfxPoolItem& ImpEditEngine::GetParaAttrib( USHORT nPara, USHORT nWhich ) const +/*N*/ { +/*N*/ ContentNode* pNode = aEditDoc.GetObject( nPara ); +/*N*/ DBG_ASSERT( pNode, "Node nicht gefunden: GetParaAttrib" ); +/*N*/ +/*N*/ return pNode->GetContentAttribs().GetItem( nWhich ); +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_svxacorr.cxx b/binfilter/bf_svx/source/editeng/svx_svxacorr.cxx new file mode 100644 index 000000000000..a8049b30a2a9 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_svxacorr.cxx @@ -0,0 +1,408 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#define ITEMID_UNDERLINE 0 +#define ITEMID_WEIGHT 0 +#define ITEMID_ESCAPEMENT 0 +#define ITEMID_CHARSETCOLOR 0 +#define ITEMID_COLOR 0 + +#include <vcl/svapp.hxx> +#include <bf_sfx2/docfile.hxx> +// fuer die Sort-String-Arrays aus dem SVMEM.HXX +#define _SVSTDARR_STRINGSISORTDTOR +#define _SVSTDARR_STRINGSDTOR + +#include <unotools/charclass.hxx> +#include <com/sun/star/i18n/UnicodeType.hdl> + +#include <svxids.hrc> + +#include "escpitem.hxx" +#include "svxacorr.hxx" + +#include <helpid.hrc> + +#include <unotools/streamwrap.hxx> +#include <bf_xmloff/xmltoken.hxx> +namespace binfilter { + +using namespace ::com::sun::star::ucb; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; +using namespace ::binfilter::xmloff::token; +using namespace ::rtl; +using namespace ::utl; + +const int C_NONE = 0x00; +const int C_FULL_STOP = 0x01; +const int C_EXCLAMATION_MARK = 0x02; +const int C_QUESTION_MARK = 0x04; + +static const sal_Char pImplWrdStt_ExcptLstStr[] = "WordExceptList"; +static const sal_Char pImplCplStt_ExcptLstStr[] = "SentenceExceptList"; +static const sal_Char pImplAutocorr_ListStr[] = "DocumentList"; +static const sal_Char pXMLImplWrdStt_ExcptLstStr[] = "WordExceptList.xml"; +static const sal_Char pXMLImplCplStt_ExcptLstStr[] = "SentenceExceptList.xml"; +static const sal_Char pXMLImplAutocorr_ListStr[] = "DocumentList.xml"; + +static const sal_Char + /* auch bei diesen Anfaengen - Klammern auf und alle Arten von Anf.Zei. */ + sImplSttSkipChars[] = "\"\'([{\x83\x84\x89\x91\x92\x93\x94", + /* auch bei diesen Ende - Klammern auf und alle Arten von Anf.Zei. */ + sImplEndSkipChars[] = "\"\')]}\x83\x84\x89\x91\x92\x93\x94"; + +// diese Zeichen sind in Worten erlaubt: (fuer FnCptlSttSntnc) +static const sal_Char sImplWordChars[] = "-'"; + +void EncryptBlockName_Imp( String& rName ); +void DecryptBlockName_Imp( String& rName ); + + +// FileVersions Nummern fuer die Ersetzungs-/Ausnahmelisten getrennt +#define WORDLIST_VERSION_358 1 +#define EXEPTLIST_VERSION_358 0 + + + +/*N*/ typedef SvxAutoCorrectLanguageLists* SvxAutoCorrectLanguageListsPtr; +/*N*/ DECLARE_TABLE( SvxAutoCorrLanguageTable_Impl, SvxAutoCorrectLanguageListsPtr)//STRIP008 ; + +/*N*/ DECLARE_TABLE( SvxAutoCorrLastFileAskTable_Impl, long )//STRIP008 ; + + + + + + + + + + // wird nach dem austauschen der Zeichen von den Funktionen + // - FnCptlSttWrd + // - FnCptlSttSntnc + // gerufen. Dann koennen die Worte ggfs. in die Ausnahmelisten + // aufgenommen werden. + + + +/*N*/ static USHORT GetAppLang() +/*N*/ { +/*N*/ return Application::GetSettings().GetLanguage(); +/*N*/ } + + + + + +/* -----------------18.11.98 15:28------------------- + * + * --------------------------------------------------*/ +/*N*/ void lcl_ClearTable(SvxAutoCorrLanguageTable_Impl& rLangTable) +/*N*/ { +/*N*/ SvxAutoCorrectLanguageListsPtr pLists = rLangTable.Last(); +/*N*/ while(pLists) +/*N*/ { +/*?*/ delete pLists; +/*?*/ pLists = rLangTable.Prev(); +/*N*/ } +/*N*/ rLangTable.Clear(); +/*N*/ } + +/* -----------------19.11.98 10:15------------------- + * + * --------------------------------------------------*/ +/*N*/ long SvxAutoCorrect::GetDefaultFlags() +/*N*/ { +/*N*/ long nRet = Autocorrect +/*N*/ | CptlSttSntnc +/*N*/ | CptlSttWrd +/*N*/ | ChgFractionSymbol +/*N*/ | ChgOrdinalNumber +/*N*/ | ChgToEnEmDash +/*N*/ | ChgWeightUnderl +/*N*/ | SetINetAttr +/*N*/ | ChgQuotes +/*N*/ | SaveWordCplSttLst +/*N*/ | SaveWordWrdSttLst; +/*N*/ LanguageType eLang = GetAppLang(); +/*N*/ switch( eLang ) +/*N*/ { +/*N*/ case LANGUAGE_ENGLISH: +/*N*/ case LANGUAGE_ENGLISH_US: +/*N*/ case LANGUAGE_ENGLISH_UK: +/*N*/ case LANGUAGE_ENGLISH_AUS: +/*N*/ case LANGUAGE_ENGLISH_CAN: +/*N*/ case LANGUAGE_ENGLISH_NZ: +/*N*/ case LANGUAGE_ENGLISH_EIRE: +/*N*/ case LANGUAGE_ENGLISH_SAFRICA: +/*N*/ case LANGUAGE_ENGLISH_JAMAICA: +/*N*/ case LANGUAGE_ENGLISH_CARRIBEAN: +/*N*/ nRet &= ~(ChgQuotes|ChgSglQuotes); +/*N*/ break; +/*N*/ } +/*N*/ return nRet; +/*N*/ } + + +/*N*/ SvxAutoCorrect::SvxAutoCorrect( const String& rShareAutocorrFile, +/*N*/ const String& rUserAutocorrFile ) +/*N*/ : sShareAutoCorrFile( rShareAutocorrFile ), +/*N*/ sUserAutoCorrFile( rUserAutocorrFile ), +/*N*/ cStartSQuote( 0 ), cEndSQuote( 0 ), cStartDQuote( 0 ), cEndDQuote( 0 ), +/*N*/ pLangTable( new SvxAutoCorrLanguageTable_Impl ), +/*N*/ pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ), +/*N*/ pCharClass( 0 ) +/*N*/ { +/*N*/ nFlags = SvxAutoCorrect::GetDefaultFlags(); +/*N*/ +/*N*/ c1Div2 = ByteString::ConvertToUnicode( '\xBD', RTL_TEXTENCODING_MS_1252 ); +/*N*/ c1Div4 = ByteString::ConvertToUnicode( '\xBC', RTL_TEXTENCODING_MS_1252 ); +/*N*/ c3Div4 = ByteString::ConvertToUnicode( '\xBE', RTL_TEXTENCODING_MS_1252 ); +/*N*/ cEmDash = ByteString::ConvertToUnicode( '\x97', RTL_TEXTENCODING_MS_1252 ); +/*N*/ cEnDash = ByteString::ConvertToUnicode( '\x96', RTL_TEXTENCODING_MS_1252 ); +/*N*/ } + +/*N*/ SvxAutoCorrect::SvxAutoCorrect( const SvxAutoCorrect& rCpy ) +/*N*/ : nFlags( rCpy.nFlags & ~(ChgWordLstLoad|CplSttLstLoad|WrdSttLstLoad)), +/*N*/ aSwFlags( rCpy.aSwFlags ), +/* Die Sprachentabelle wird neu aufgebaut, da sie im Dtor von rCpy abgeraeumt wird! + */ +/*N*/ sShareAutoCorrFile( rCpy.sShareAutoCorrFile ), +/*N*/ sUserAutoCorrFile( rCpy.sUserAutoCorrFile ), +/*N*/ cStartSQuote( rCpy.cStartSQuote ), cEndSQuote( rCpy.cEndSQuote ), +/*N*/ cStartDQuote( rCpy.cStartDQuote ), cEndDQuote( rCpy.cEndDQuote ), +/*N*/ c1Div2( rCpy.c1Div2 ), c1Div4( rCpy.c1Div4 ), c3Div4( rCpy.c3Div4 ), +/*N*/ cEmDash( rCpy.cEmDash ), cEnDash( rCpy.cEnDash ), +/*N*/ pLangTable( new SvxAutoCorrLanguageTable_Impl ), +/*N*/ pLastFileTable( new SvxAutoCorrLastFileAskTable_Impl ), +/*N*/ pCharClass( 0 ) +/*N*/ { +/*N*/ } + + +/*N*/ SvxAutoCorrect::~SvxAutoCorrect() +/*N*/ { +/*N*/ lcl_ClearTable(*pLangTable); +/*N*/ delete pLangTable; +/*N*/ delete pLastFileTable; +/*N*/ delete pCharClass; +/*N*/ } + + +/*N*/ void SvxAutoCorrect::SetAutoCorrFlag( long nFlag, BOOL bOn ) +/*N*/ { +/*N*/ long nOld = nFlags; +/*N*/ nFlags = bOn ? nFlags | nFlag +/*N*/ : nFlags & ~nFlag; +/*N*/ +/*N*/ if( !bOn ) +/*N*/ { +/*N*/ if( (nOld & CptlSttSntnc) != (nFlags & CptlSttSntnc) ) +/*?*/ nFlags &= ~CplSttLstLoad; +/*N*/ if( (nOld & CptlSttWrd) != (nFlags & CptlSttWrd) ) +/*?*/ nFlags &= ~WrdSttLstLoad; +/*N*/ if( (nOld & Autocorrect) != (nFlags & Autocorrect) ) +/*?*/ nFlags &= ~ChgWordLstLoad; +/*N*/ } +/*N*/ } + + + // Zwei Grossbuchstaben am Wort-Anfang ?? + + + + + + + + + + + + +//The method below is renamed from _GetQuote to GetQuote by BerryJia for Bug95846 Time:2002-8-13 15:50 + + + + + + + + // fuegt ein einzelnes Wort hinzu. Die Liste wird sofort + // in die Datei geschrieben! + + + // fuegt ein einzelnes Wort hinzu. Die Liste wird sofort + // in die Datei geschrieben! + + + + + + + + + + + + // - loesche einen Eintrag + + + // - return den Ersetzungstext (nur fuer SWG-Format, alle anderen + // koennen aus der Wortliste herausgeholt werden!) + + // - Text mit Attributierung (kann nur der SWG - SWG-Format!) + + + + +/* This code is copied from SwXMLTextBlocks::GeneratePackageName */ + + + +/* -----------------18.11.98 16:00------------------- + * + * --------------------------------------------------*/ + + +// suche das oder die Worte in der ErsetzungsTabelle +/* -----------------18.11.98 13:46------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 14:28------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 14:49------------------- + * + * --------------------------------------------------*/ + +/* -----------------20.11.98 11:53------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:16------------------- + * + * --------------------------------------------------*/ +/*N*/ SvxAutoCorrectLanguageLists::SvxAutoCorrectLanguageLists( +/*N*/ SvxAutoCorrect& rParent, +/*N*/ const String& rShareAutoCorrectFile, +/*N*/ const String& rUserAutoCorrectFile, +/*N*/ LanguageType eLang) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/* -----------------18.11.98 11:16------------------- + * + * --------------------------------------------------*/ +/*N*/ SvxAutoCorrectLanguageLists::~SvxAutoCorrectLanguageLists() +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 15:20------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + // - Text mit Attributierung (kann nur der SWG - SWG-Format!) + +/* -----------------18.11.98 11:26------------------- + * + * --------------------------------------------------*/ + // - loesche einen Eintrag +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_swafopt.cxx b/binfilter/bf_svx/source/editeng/svx_swafopt.cxx new file mode 100644 index 000000000000..9e2e061ff5ec --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_swafopt.cxx @@ -0,0 +1,104 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <vcl/keycodes.hxx> + +#include "swafopt.hxx" +namespace binfilter { + +/*------------------------------------------------------------------------ + Beschreibung: +------------------------------------------------------------------------*/ + +/*N*/ SvxSwAutoFmtFlags& SvxSwAutoFmtFlags::operator=( const SvxSwAutoFmtFlags& rAFFlags ) +/*N*/ { +/*N*/ bAutoCorrect = rAFFlags.bAutoCorrect; +/*N*/ bReplaceQuote = rAFFlags.bReplaceQuote; +/*N*/ bCptlSttSntnc = rAFFlags.bCptlSttSntnc; +/*N*/ bCptlSttWrd = rAFFlags.bCptlSttWrd; +/*N*/ bChkFontAttr = rAFFlags.bChkFontAttr; +/*N*/ +/*N*/ bChgUserColl = rAFFlags.bChgUserColl; +/*N*/ bChgEnumNum = rAFFlags.bChgEnumNum; +/*N*/ bDelEmptyNode = rAFFlags.bDelEmptyNode; +/*N*/ bSetNumRule = rAFFlags.bSetNumRule; +/*N*/ bAFmtByInput = rAFFlags.bAFmtByInput; +/*N*/ +/*N*/ bChgFracionSymbol = rAFFlags.bChgFracionSymbol; +/*N*/ bChgOrdinalNumber = rAFFlags.bChgOrdinalNumber; +/*N*/ bChgToEnEmDash = rAFFlags.bChgToEnEmDash; +/*N*/ bChgWeightUnderl = rAFFlags.bChgWeightUnderl; +/*N*/ bSetINetAttr = rAFFlags.bSetINetAttr; +/*N*/ bSetBorder = rAFFlags.bSetBorder; +/*N*/ bCreateTable = rAFFlags.bCreateTable; +/*N*/ bReplaceStyles = rAFFlags.bReplaceStyles; +/*N*/ bAFmtDelSpacesAtSttEnd = rAFFlags.bAFmtDelSpacesAtSttEnd; +/*N*/ bAFmtDelSpacesBetweenLines = rAFFlags.bAFmtDelSpacesBetweenLines; +/*N*/ bAFmtByInpDelSpacesAtSttEnd = rAFFlags.bAFmtByInpDelSpacesAtSttEnd; +/*N*/ bAFmtByInpDelSpacesBetweenLines = rAFFlags.bAFmtByInpDelSpacesBetweenLines; +/*N*/ +/*N*/ bDummy = rAFFlags.bDummy; +/*N*/ +/*N*/ bDummy5 = rAFFlags.bDummy5; +/*N*/ bDummy6 = rAFFlags.bDummy6; +/*N*/ bDummy7 = rAFFlags.bDummy7; +/*N*/ bDummy8 = rAFFlags.bDummy8; +/*N*/ +/*N*/ bWithRedlining = rAFFlags.bWithRedlining; +/*N*/ +/*N*/ bRightMargin = rAFFlags.bRightMargin; +/*N*/ nRightMargin = rAFFlags.nRightMargin; +/*N*/ +/*N*/ cBullet = rAFFlags.cBullet; +/*N*/ aBulletFont = rAFFlags.aBulletFont; +/*N*/ +/*N*/ cByInputBullet = rAFFlags.cByInputBullet; +/*N*/ aByInputBulletFont = rAFFlags.aByInputBulletFont; +/*N*/ +/*N*/ bAutoCompleteWords = rAFFlags.bAutoCompleteWords; +/*N*/ bAutoCmpltCollectWords = rAFFlags.bAutoCmpltCollectWords; +/*N*/ bAutoCmpltKeepList = rAFFlags.bAutoCmpltKeepList; +/*N*/ bAutoCmpltEndless = rAFFlags.bAutoCmpltEndless; +/*N*/ bAutoCmpltAppendBlanc = rAFFlags.bAutoCmpltAppendBlanc; +/*N*/ bAutoCmpltShowAsTip = rAFFlags.bAutoCmpltShowAsTip; +/*N*/ pAutoCmpltList = rAFFlags.pAutoCmpltList; +/*N*/ nAutoCmpltExpandKey = rAFFlags.nAutoCmpltExpandKey; +/*N*/ +/*N*/ nAutoCmpltWordLen = rAFFlags.nAutoCmpltWordLen; +/*N*/ nAutoCmpltListLen = rAFFlags.nAutoCmpltListLen; +/*N*/ +/*N*/ return *this; +/*N*/ } + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_txtrange.cxx b/binfilter/bf_svx/source/editeng/svx_txtrange.cxx new file mode 100644 index 000000000000..acb00a348b1b --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_txtrange.cxx @@ -0,0 +1,663 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <xoutx.hxx> + +#include "txtrange.hxx" +#include <math.h> + + +namespace binfilter { + +/************************************************************************* +|* +|* TextRanger::TextRanger() +|* +|* Beschreibung +|* Ersterstellung 20.01.97 +|* Letzte Aenderung 20.01.97 AMA +|* +*************************************************************************/ + +#ifdef WIN +#pragma optimize ( "", off ) +#endif + +/*N*/ TextRanger::TextRanger( const XPolyPolygon& rXPoly, const XPolyPolygon* pXLine, +/*N*/ USHORT nCacheSz, USHORT nLft, USHORT nRght, BOOL bSimpl, BOOL bInnr, +/*N*/ BOOL bVert ) : +/*N*/ pBound( NULL ), nCacheSize( nCacheSz ), nCacheIdx( 0 ), nPointCount( 0 ), +/*N*/ nLeft( nLft ), nRight( nRght ), nUpper( 0 ), nLower( 0 ), +/*N*/ bSimple( bSimpl ), bInner( bInnr ), bVertical( bVert ) +/*N*/ { +/*N*/ #ifdef DBG_UTIL +/*N*/ bFlag3 = bFlag4 = bFlag5 = bFlag6 = bFlag7 = FALSE; +/*N*/ #endif +/*N*/ pRangeArr = new Range[ nCacheSize ]; +/*N*/ pCache = new SvLongsPtr[ nCacheSize ]; +/*N*/ memset( pRangeArr, 0, nCacheSize * sizeof( Range ) ); +/*N*/ memset( pCache, 0, nCacheSize * sizeof( SvLongsPtr ) ); +/*N*/ USHORT nCount = rXPoly.Count(); +/*N*/ pPoly = new PolyPolygon( nCount ); +/*N*/ for( USHORT i = 0; i < nCount; ++i ) +/*N*/ { +/*N*/ Polygon aTmp = XOutCreatePolygon( rXPoly[ i ], NULL, 100 ); +/*N*/ nPointCount += aTmp.GetSize(); +/*N*/ pPoly->Insert( aTmp, i ); +/*N*/ } +/*N*/ if( pXLine ) +/*N*/ { +/*N*/ nCount = pXLine->Count(); +/*N*/ pLine = new PolyPolygon(); +/*N*/ for( USHORT i = 0; i < nCount; ++i ) +/*N*/ { +/*N*/ Polygon aTmp = XOutCreatePolygon( (*pXLine)[ i ], NULL, 100 ); +/*N*/ nPointCount += aTmp.GetSize(); +/*N*/ pLine->Insert( aTmp, i ); +/*N*/ } +/*N*/ } +/*N*/ else +/*N*/ pLine = NULL; +/*N*/ +/*N*/ #if 0 +/*N*/ ULONG nPolyPtr = (ULONG)&rXPoly; +/*N*/ String aDbgFile( "d:\\" ); +/*N*/ aDbgFile += nPolyPtr; +/*N*/ aDbgFile += ".pol"; +/*N*/ SvFileStream aStream( aDbgFile, STREAM_WRITE|STREAM_TRUNC ); +/*N*/ aStream << "pPoly: " << String( (ULONG)pPoly ).GetStr(); +/*N*/ for ( USHORT nPoly = 0; nPoly < pPoly->Count(); nPoly++ ) +/*N*/ { +/*N*/ const Polygon& rPoly = pPoly->GetObject( nPoly ); +/*N*/ for ( USHORT n = 0; n < rPoly.GetSize(); n++ ) +/*N*/ { +/*N*/ const Point& rPoint = rPoly.GetPoint( n ); +/*N*/ aStream << String( rPoint.X() ).GetStr() << ", " << String( rPoint.Y() ).GetStr() << endl; +/*N*/ } +/*N*/ } +/*N*/ #endif +/*N*/ } + +#ifdef WIN +#pragma optimize ( "", on ) +#endif + +/************************************************************************* +|* +|* TextRanger::~TextRanger() +|* +|* Beschreibung +|* Ersterstellung 20.01.97 +|* Letzte Aenderung 20.01.97 AMA +|* +*************************************************************************/ + +/*N*/ TextRanger::~TextRanger() +/*N*/ { +/*N*/ for( USHORT i = 0; i < nCacheSize; ++i ) +/*N*/ delete pCache[i]; +/*N*/ delete[] pCache; +/*N*/ delete[] pRangeArr; +/*N*/ delete pPoly; +/*N*/ delete pLine; +/*N*/ } + +/*-----------------17.11.00 09:49------------------- + * TextRanger::SetVertical(..) + * If there's is a change in the writing direction, + * the cache has to be cleared. + * --------------------------------------------------*/ + + +/************************************************************************* +|* +|* SvxBoundArgs +|* +|* Beschreibung +|* Ersterstellung 20.01.97 +|* Letzte Aenderung 20.01.97 AMA +|* +*************************************************************************/ + +/*N*/ class SvxBoundArgs +/*N*/ { +/*N*/ SvBools aBoolArr; +/*N*/ SvLongs *pLongArr; +/*N*/ TextRanger *pTextRanger; +/*N*/ long nMin; +/*N*/ long nMax; +/*N*/ long nTop; +/*N*/ long nBottom; +/*N*/ long nUpDiff; +/*N*/ long nLowDiff; +/*N*/ long nUpper; +/*N*/ long nLower; +/*N*/ long nStart; +/*N*/ long nEnd; +/*N*/ USHORT nCut; +/*N*/ USHORT nLast; +/*N*/ USHORT nNext; +/*N*/ BYTE nAct; +/*N*/ BYTE nFirst; +/*N*/ BOOL bClosed : 1; +/*N*/ BOOL bInner : 1; +/*N*/ BOOL bMultiple : 1; +/*N*/ BOOL bConcat : 1; +/*N*/ BOOL bRotate : 1; +/*N*/ void NoteRange( BOOL bToggle ); +/*N*/ long Cut( long nY, const Point& rPt1, const Point& rPt2 ); +/*N*/ void Add(); +/*N*/ void CheckCut( const Point& rLst, const Point& rNxt ); +/*N*/ inline long A( const Point& rP ) const { return bRotate ? rP.Y() : rP.X(); } +/*N*/ inline long B( const Point& rP ) const { return bRotate ? rP.X() : rP.Y(); } +/*N*/ public: +/*N*/ SvxBoundArgs( TextRanger* pRanger, SvLongs *pLong, const Range& rRange ); +/*N*/ void NotePoint( const long nA ) { NoteMargin( nA - nStart, nA + nEnd ); } +/*N*/ void NoteMargin( const long nL, const long nR ) +/*N*/ { if( nMin > nL ) nMin = nL; if( nMax < nR ) nMax = nR; } +/*N*/ USHORT Area( const Point& rPt ); +/*N*/ void NoteUpLow( long nA, const BYTE nArea ); +/*N*/ void Calc( const PolyPolygon& rPoly ); +/*N*/ void Concat( const PolyPolygon* pPoly ); +/*N*/ // inlines +/*N*/ void NoteLast() { if( bMultiple ) NoteRange( nAct == nFirst ); } +/*N*/ void SetClosed( const BOOL bNew ){ bClosed = bNew; } +/*N*/ BOOL IsClosed() const { return bClosed; } +/*N*/ void SetConcat( const BOOL bNew ){ bConcat = bNew; } +/*N*/ BOOL IsConcat() const { return bConcat; } +/*N*/ BYTE GetAct() const { return nAct; } +/*N*/ }; + +/*N*/ SvxBoundArgs::SvxBoundArgs( TextRanger* pRanger, SvLongs *pLong, +/*N*/ const Range& rRange ) +/*N*/ : aBoolArr( 4, 4 ), pLongArr( pLong ), pTextRanger( pRanger ), +/*N*/ nTop( rRange.Min() ), nBottom( rRange.Max() ), +/*N*/ bInner( pRanger->IsInner() ), bMultiple( bInner || !pRanger->IsSimple() ), +/*N*/ bConcat( FALSE ), bRotate( pRanger->IsVertical() ) +/*N*/ { +/*N*/ if( bRotate ) +/*N*/ { +/*?*/ nStart = pRanger->GetUpper(); +/*?*/ nEnd = pRanger->GetLower(); +/*?*/ nLowDiff = pRanger->GetLeft(); +/*?*/ nUpDiff = pRanger->GetRight(); +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nStart = pRanger->GetLeft(); +/*N*/ nEnd = pRanger->GetRight(); +/*N*/ nLowDiff = pRanger->GetUpper(); +/*N*/ nUpDiff = pRanger->GetLower(); +/*N*/ } +/*N*/ nUpper = nTop - nUpDiff; +/*N*/ nLower = nBottom + nLowDiff; +/*N*/ pLongArr->Remove( 0, pLongArr->Count() ); +/*N*/ } + + +/*N*/ void SvxBoundArgs::CheckCut( const Point& rLst, const Point& rNxt ) +/*N*/ { +/*N*/ if( nCut & 1 ) +/*N*/ NotePoint( Cut( nBottom, rLst, rNxt ) ); +/*N*/ if( nCut & 2 ) +/*N*/ NotePoint( Cut( nTop, rLst, rNxt ) ); +/*N*/ if( rLst.X() != rNxt.X() && rLst.Y() != rNxt.Y() ) +/*N*/ { +/*N*/ long nYps; +/*N*/ if( nLowDiff && ( ( nCut & 1 ) || nLast == 1 || nNext == 1 ) ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 nYps = CalcMax( rLst, rNxt, nBottom, nLower ); +/*N*/ } +/*N*/ if( nUpDiff && ( ( nCut & 2 ) || nLast == 2 || nNext == 2 ) ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 nYps = CalcMax( rLst, rNxt, nTop, nUpper ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void SvxBoundArgs::NoteRange( BOOL bToggle ) +/*N*/ { +/*N*/ DBG_ASSERT( nMax >= nMin || bInner, "NoteRange: Min > Max?"); +/*N*/ if( nMax < nMin ) +/*N*/ return; +/*N*/ if( !bClosed ) +/*N*/ bToggle = FALSE; +/*N*/ USHORT nIdx = 0; +/*N*/ USHORT nCount = pLongArr->Count(); +/*N*/ DBG_ASSERT( nCount == 2 * aBoolArr.Count(), "NoteRange: Incompatible Sizes" ); +/*N*/ while( nIdx < nCount && (*pLongArr)[ nIdx ] < nMin ) +/*N*/ ++nIdx; +/*N*/ BOOL bOdd = nIdx % 2 ? TRUE : FALSE; +/*N*/ // Kein Ueberlappung mit vorhandenen Intervallen? +/*N*/ if( nIdx == nCount || ( !bOdd && nMax < (*pLongArr)[ nIdx ] ) ) +/*N*/ { // Dann wird ein neues eingefuegt ... +/*N*/ pLongArr->Insert( nMin, nIdx ); +/*N*/ pLongArr->Insert( nMax, nIdx + 1 ); +/*N*/ aBoolArr.Insert( bToggle, nIdx / 2 ); +/*N*/ } +/*N*/ else +/*N*/ { // ein vorhandes Intervall erweitern ... +/*N*/ USHORT nMaxIdx = nIdx; +/*N*/ // Wenn wir auf einer linken Intervallgrenze gelandet sind, muss diese +/*N*/ // auf nMin gesenkt werden. +/*N*/ if( bOdd ) +/*N*/ --nIdx; +/*N*/ else +/*N*/ (*pLongArr)[ nIdx ] = nMin; +/*N*/ while( nMaxIdx < nCount && (*pLongArr)[ nMaxIdx ] < nMax ) +/*N*/ ++nMaxIdx; +/*N*/ DBG_ASSERT( nMaxIdx > nIdx || nMin == nMax, "NoteRange: Funny Situation." ); +/*N*/ if( nMaxIdx ) +/*N*/ --nMaxIdx; +/*N*/ if( nMaxIdx < nIdx ) +/*N*/ nMaxIdx = nIdx; +/*N*/ // Wenn wir auf einer rechten Intervallgrenze landen, muss diese +/*N*/ // auf nMax angehoben werden. +/*N*/ if( nMaxIdx % 2 ) +/*N*/ (*pLongArr)[ nMaxIdx-- ] = nMax; +/*N*/ // Jetzt werden eventuell noch Intervalle verschmolzen +/*N*/ USHORT nDiff = nMaxIdx - nIdx; +/*N*/ nMaxIdx = nIdx / 2; // Ab hier ist nMaxIdx der Index im BoolArray. +/*N*/ if( nDiff ) +/*N*/ { +/*N*/ (*pLongArr).Remove( nIdx + 1, nDiff ); +/*N*/ nDiff /= 2; +/*N*/ USHORT nStop = nMaxIdx + nDiff; +/*N*/ for( USHORT i = nMaxIdx; i < nStop; ++i ) +/*N*/ bToggle ^= aBoolArr[ i ]; +/*N*/ aBoolArr.Remove( nMaxIdx, nDiff ); +/*N*/ } +/*N*/ DBG_ASSERT( nMaxIdx < aBoolArr.Count(), "NoteRange: Too much deleted" ); +/*N*/ aBoolArr[ nMaxIdx ] ^= bToggle; +/*N*/ } +/*N*/ } + +/*N*/ void SvxBoundArgs::Calc( const PolyPolygon& rPoly ) +/*N*/ { +/*N*/ USHORT nCount; +/*N*/ nAct = 0; +/*N*/ for( USHORT i = 0; i < rPoly.Count(); ++i ) +/*N*/ { +/*N*/ const Polygon& rPol = rPoly[ i ]; +/*N*/ nCount = rPol.GetSize(); +/*N*/ if( nCount ) +/*N*/ { +/*N*/ const Point& rNull = rPol[ 0 ]; +/*N*/ SetClosed( IsConcat() || ( rNull == rPol[ nCount - 1 ] ) ); +/*N*/ nLast = Area( rNull ); +/*N*/ if( nLast & 12 ) +/*N*/ { +/*N*/ nFirst = 3; +/*N*/ if( bMultiple ) +/*N*/ nAct = 0; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ // Der erste Punkt des Polygons liegt innerhalb der Zeile. +/*N*/ if( nLast ) +/*N*/ { +/*?*/ DBG_BF_ASSERT(0, "STRIP"); //STRIP001 if( bMultiple || !nAct ) +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ if( bMultiple || !nAct ) +/*N*/ { +/*N*/ nMin = A(rNull); +/*N*/ nMax = nMin + nEnd; +/*N*/ nMin -= nStart; +/*N*/ } +/*N*/ else +/*?*/ NotePoint( A(rNull) ); +/*N*/ } +/*N*/ nFirst = 0; // In welcher Richtung wird die Zeile verlassen? +/*N*/ nAct = 3; // Wir sind z.Z. innerhalb der Zeile. +/*N*/ } +/*N*/ if( nCount > 1 ) +/*N*/ { +/*N*/ USHORT nIdx = 1; +/*N*/ while( TRUE ) +/*N*/ { +/*N*/ const Point& rLast = rPol[ nIdx - 1 ]; +/*N*/ if( nIdx == nCount ) +/*N*/ nIdx = 0; +/*N*/ const Point& rNext = rPol[ nIdx ]; +/*N*/ nNext = Area( rNext ); +/*N*/ nCut = nNext ^ nLast; +/*N*/ USHORT nOldAct = nAct; +/*N*/ if( nAct ) +/*N*/ CheckCut( rLast, rNext ); +/*N*/ if( nCut & 4 ) +/*N*/ { +/*N*/ NoteUpLow( Cut( nLower, rLast, rNext ), 2 ); +/*N*/ if( nAct && nAct != nOldAct ) +/*N*/ { +/*N*/ nOldAct = nAct; +/*N*/ CheckCut( rLast, rNext ); +/*N*/ } +/*N*/ } +/*N*/ if( nCut & 8 ) +/*N*/ { +/*N*/ NoteUpLow( Cut( nUpper, rLast, rNext ), 1 ); +/*N*/ if( nAct && nAct != nOldAct ) +/*N*/ CheckCut( rLast, rNext ); +/*N*/ } +/*N*/ if( !nIdx ) +/*N*/ { +/*N*/ if( !( nNext & 12 ) ) +/*N*/ NoteLast(); +/*N*/ break; +/*N*/ } +/*N*/ if( !( nNext & 12 ) ) +/*N*/ { +/*N*/ if( !nNext ) +/*N*/ NotePoint( A(rNext) ); +/*N*/ else if( nNext & 1 ) +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 NoteFarPoint( A(rNext), nLower-B(rNext), nLowDiff ); +/*N*/ else +/*?*/ {DBG_BF_ASSERT(0, "STRIP");} //STRIP001 NoteFarPoint( A(rNext), B(rNext)-nUpper, nUpDiff ); +/*N*/ } +/*N*/ nLast = nNext; +/*N*/ if( ++nIdx == nCount && !IsClosed() ) +/*N*/ { +/*N*/ if( !( nNext & 12 ) ) +/*N*/ NoteLast(); +/*N*/ break; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if( bMultiple && IsConcat() ) +/*N*/ { +/*N*/ Add(); +/*N*/ nAct = 0; +/*N*/ } +/*N*/ } +/*N*/ } +/*N*/ if( !bMultiple ) +/*N*/ { +/*?*/ DBG_ASSERT( pLongArr->Count() == 0, "I said: Simple!" ); +/*?*/ if( nAct ) +/*?*/ { +/*?*/ if( bInner ) +/*?*/ { +/*?*/ long nTmpMin, nTmpMax; +/*?*/ { +/*?*/ nTmpMin = nMin + 2 * nStart; +/*?*/ nTmpMax = nMax - 2 * nEnd; +/*?*/ if( nTmpMin <= nTmpMax ) +/*?*/ { +/*?*/ pLongArr->Insert( nTmpMin, 0 ); +/*?*/ pLongArr->Insert( nTmpMax, 1 ); +/*?*/ } +/*?*/ } +/*?*/ } +/*?*/ else +/*?*/ { +/*?*/ pLongArr->Insert( nMin, 0 ); +/*?*/ pLongArr->Insert( nMax, 1 ); +/*?*/ } +/*?*/ } +/*N*/ } +/*N*/ else if( !IsConcat() ) +/*N*/ Add(); +/*N*/ } + +/*N*/ void SvxBoundArgs::Add() +/*N*/ { +/*N*/ USHORT nLongIdx = 1; +/*N*/ USHORT nCount = aBoolArr.Count(); +/*N*/ if( nCount && ( !bInner || !pTextRanger->IsSimple() ) ) +/*N*/ { +/*N*/ BOOL bDelete = aBoolArr[ 0 ]; +/*N*/ if( bInner ) +/*N*/ bDelete = !bDelete; +/*N*/ for( USHORT nBoolIdx = 1; nBoolIdx < nCount; ++nBoolIdx ) +/*N*/ { +/*N*/ if( bDelete ) +/*N*/ { +/*N*/ USHORT nNext = 2; +/*N*/ while( nBoolIdx < nCount && !aBoolArr[ nBoolIdx++ ] && +/*N*/ (!bInner || nBoolIdx < nCount ) ) +/*N*/ nNext += 2; +/*N*/ pLongArr->Remove( nLongIdx, nNext ); +/*N*/ nNext /= 2; +/*N*/ nBoolIdx -= nNext; +/*N*/ nCount -= nNext; +/*N*/ aBoolArr.Remove( nBoolIdx, nNext ); +/*N*/ if( nBoolIdx ) +/*N*/ aBoolArr[ nBoolIdx - 1 ] = FALSE; +/*N*/ #if OSL_DEBUG_LEVEL > 1 +/*N*/ else +/*N*/ ++nNext; +/*N*/ #endif +/*N*/ } +/*N*/ bDelete = nBoolIdx < nCount && aBoolArr[ nBoolIdx ]; +/*N*/ nLongIdx += 2; +/*N*/ DBG_ASSERT( nLongIdx == 2*nBoolIdx+1, "BoundArgs: Array-Idx Confusion" ); +/*N*/ DBG_ASSERT( aBoolArr.Count()*2 == pLongArr->Count(), +/*N*/ "BoundArgs: Array-Count: Confusion" ); +/*N*/ } +/*N*/ } +/*N*/ if( 0 != ( nCount = pLongArr->Count() ) ) +/*N*/ { +/*N*/ if( bInner ) +/*N*/ { +/*?*/ pLongArr->Remove( 0, 1 ); +/*?*/ pLongArr->Remove( pLongArr->Count() - 1, 1 ); +/*?*/ +/*?*/ // Hier wird die Zeile beim "einfachen" Konturumfluss im Innern +/*?*/ // in ein grosses Rechteck zusammengefasst. +/*?*/ // Zur Zeit (April 1999) wertet die EditEngine nur das erste Rechteck +/*?*/ // aus, falls sie eines Tages in der Lage ist, eine Zeile in mehreren +/*?*/ // Teilen auszugeben, kann es sinnvoll sein, die folgenden Zeilen +/*?*/ // zu loeschen. +/*?*/ if( pTextRanger->IsSimple() && pLongArr->Count() > 2 ) +/*?*/ pLongArr->Remove( 1, pLongArr->Count() - 2 ); +/*?*/ +/*N*/ } +/*N*/ } +/*N*/ } + +/*N*/ void SvxBoundArgs::Concat( const PolyPolygon* pPoly ) +/*N*/ { +/*N*/ SetConcat( TRUE ); +/*N*/ DBG_ASSERT( pPoly, "Nothing to do?" ); +/*N*/ SvLongs *pOld = pLongArr; +/*N*/ pLongArr = new SvLongs( 2, 8 ); +/*N*/ aBoolArr.Remove( 0, aBoolArr.Count() ); +/*N*/ bInner = FALSE; +/*N*/ Calc( *pPoly ); +/*N*/ USHORT nCount = pLongArr->Count(); +/*N*/ USHORT nIdx = 0; +/*N*/ USHORT i = 0; +/*N*/ BOOL bSubtract = pTextRanger->IsInner(); +/*N*/ while( i < nCount ) +/*N*/ { +/*N*/ USHORT nOldCount = pOld->Count(); +/*N*/ if( nIdx == nOldCount ) +/*N*/ { // Am Ende des alten Arrays angelangt... +/*?*/ if( !bSubtract ) +/*?*/ pOld->Insert( pLongArr, nIdx, i, USHRT_MAX ); +/*?*/ break; +/*N*/ } +/*N*/ long nLeft = (*pLongArr)[ i++ ]; +/*N*/ long nRight = (*pLongArr)[ i++ ]; +/*N*/ USHORT nLeftPos = nIdx + 1; +/*N*/ while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] ) +/*N*/ nLeftPos += 2; +/*N*/ if( nLeftPos >= nOldCount ) +/*N*/ { // Das aktuelle Intervall gehoert ans Ende des alten Arrays... +/*?*/ if( !bSubtract ) +/*?*/ pOld->Insert( pLongArr, nOldCount, i - 2, USHRT_MAX ); +/*?*/ break; +/*N*/ } +/*N*/ USHORT nRightPos = nLeftPos - 1; +/*N*/ while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] ) +/*N*/ nRightPos += 2; +/*N*/ if( nRightPos < nLeftPos ) +/*N*/ { // Das aktuelle Intervall gehoert zwischen zwei alte Intervalle +/*?*/ if( !bSubtract ) +/*?*/ pOld->Insert( pLongArr, nRightPos, i - 2, i ); +/*?*/ nIdx = nRightPos + 2; +/*N*/ } +/*N*/ else if( bSubtract ) // Subtrahieren ggf. Trennen +/*N*/ { +/*?*/ long nOld; +/*?*/ if( nLeft > ( nOld = (*pOld)[ nLeftPos - 1 ] ) ) +/*?*/ { // Jetzt spalten wir den linken Teil ab... +/*?*/ if( nLeft - 1 > nOld ) +/*?*/ { +/*?*/ pOld->Insert( nOld, nLeftPos - 1 ); +/*?*/ pOld->Insert( nLeft - 1, nLeftPos ); +/*?*/ nLeftPos += 2; +/*?*/ nRightPos += 2; +/*?*/ } +/*?*/ } +/*?*/ if( nRightPos - nLeftPos > 1 ) +/*?*/ pOld->Remove( nLeftPos, nRightPos - nLeftPos - 1 ); +/*?*/ if( ++nRight >= ( nOld = (*pOld)[ nLeftPos ] ) ) +/*?*/ pOld->Remove( nLeftPos - 1, 2 ); +/*?*/ else +/*?*/ (*pOld)[ nLeftPos - 1 ] = nRight; +/*N*/ } +/*N*/ else // Verschmelzen +/*N*/ { +/*N*/ if( nLeft < (*pOld)[ nLeftPos - 1 ] ) +/*N*/ (*pOld)[ nLeftPos - 1 ] = nLeft; +/*N*/ if( nRight > (*pOld)[ nRightPos - 1 ] ) +/*N*/ (*pOld)[ nRightPos - 1 ] = nRight; +/*N*/ if( nRightPos - nLeftPos > 1 ) +/*?*/ pOld->Remove( nLeftPos, nRightPos - nLeftPos - 1 ); +/*N*/ +/*N*/ } +/*N*/ nIdx = nLeftPos - 1; +/*N*/ } +/*N*/ delete pLongArr; +/*N*/ } + +/************************************************************************* + * SvxBoundArgs::Area ermittelt den Bereich, in dem sich der Punkt befindet + * 0 = innerhalb der Zeile + * 1 = unterhalb, aber innerhalb der oberen Randes + * 2 = oberhalb, aber innerhalb der unteren Randes + * 5 = unterhalb des oberen Randes + *10 = oberhalb des unteren Randes + *************************************************************************/ + +/*N*/ USHORT SvxBoundArgs::Area( const Point& rPt ) +/*N*/ { +/*N*/ long nB = B( rPt ); +/*N*/ if( nB >= nBottom ) +/*N*/ { +/*N*/ if( nB >= nLower ) +/*N*/ return 5; +/*N*/ return 1; +/*N*/ } +/*N*/ if( nB <= nTop ) +/*N*/ { +/*N*/ if( nB <= nUpper ) +/*N*/ return 10; +/*N*/ return 2; +/*N*/ } +/*N*/ return 0; +/*N*/ } + +/************************************************************************* + * lcl_Cut berechnet die X-Koordinate der Strecke (Pt1-Pt2) auf der + * Y-Koordinate nY. + * Vorausgesetzt wird, dass einer der Punkte oberhalb und der andere + * unterhalb der Y-Koordinate liegt. + *************************************************************************/ + +/*N*/ long SvxBoundArgs::Cut( long nB, const Point& rPt1, const Point& rPt2 ) +/*N*/ { +/*N*/ if( pTextRanger->IsVertical() ) +/*N*/ { +/*?*/ double nQuot = nB - rPt1.X(); +/*?*/ nQuot /= ( rPt2.X() - rPt1.X() ); +/*?*/ nQuot *= ( rPt2.Y() - rPt1.Y() ); +/*?*/ return long( rPt1.Y() + nQuot ); +/*N*/ } +/*N*/ double nQuot = nB - rPt1.Y(); +/*N*/ nQuot /= ( rPt2.Y() - rPt1.Y() ); +/*N*/ nQuot *= ( rPt2.X() - rPt1.X() ); +/*N*/ return long( rPt1.X() + nQuot ); +/*N*/ } + +/*N*/ void SvxBoundArgs::NoteUpLow( long nA, const BYTE nArea ) +/*N*/ { +/*N*/ if( nAct ) +/*N*/ { +/*N*/ NoteMargin( nA, nA ); +/*N*/ if( bMultiple ) +/*N*/ { +/*N*/ NoteRange( nArea != nAct ); +/*N*/ nAct = 0; +/*N*/ } +/*N*/ if( !nFirst ) +/*N*/ nFirst = nArea; +/*N*/ } +/*N*/ else +/*N*/ { +/*N*/ nAct = nArea; +/*N*/ nMin = nA; +/*N*/ nMax = nA; +/*N*/ } +/*N*/ } + +/*N*/ SvLongsPtr TextRanger::GetTextRanges( const Range& rRange ) +/*N*/ { +/*N*/ DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" ); +/*N*/ USHORT nIndex = 0; +/*N*/ while( nIndex < nCacheSize && rRange != pRangeArr[ nIndex ] ) +/*N*/ ++nIndex; +/*N*/ if( nIndex >= nCacheSize ) +/*N*/ { +/*N*/ ++nCacheIdx; +/*N*/ nCacheIdx %= nCacheSize; +/*N*/ pRangeArr[ nCacheIdx ] = rRange; +/*N*/ if( !pCache[ nCacheIdx ] ) +/*N*/ pCache[ nCacheIdx ] = new SvLongs( 2, 8 ); +/*N*/ nIndex = nCacheIdx; +/*N*/ SvxBoundArgs aArg( this, pCache[ nCacheIdx ], rRange ); +/*N*/ aArg.Calc( *pPoly ); +/*N*/ if( pLine ) +/*N*/ aArg.Concat( pLine ); +/*N*/ } +/*N*/ return pCache[ nIndex ]; +/*N*/ } + + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/binfilter/bf_svx/source/editeng/svx_unolingu.cxx b/binfilter/bf_svx/source/editeng/svx_unolingu.cxx new file mode 100644 index 000000000000..f9c650817839 --- /dev/null +++ b/binfilter/bf_svx/source/editeng/svx_unolingu.cxx @@ -0,0 +1,657 @@ +/* -*- 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. + * + ************************************************************************/ + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +#include <unolingu.hxx> + +#include <cppuhelper/implbase1.hxx> // helper for implementations + +#include <tools/debug.hxx> +#include <tools/urlobj.hxx> +#include <bf_svtools/pathoptions.hxx> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/linguistic2/XAvailableLocales.hpp> +#include <comphelper/processfactory.hxx> + +#include <cppuhelper/implbase1.hxx> // helper for implementations + +#include <i18npool/mslangid.hxx> +#include <bf_svtools/lingucfg.hxx> +#include <vcl/msgbox.hxx> +#include <tools/shl.hxx> + +#include <dialmgr.hxx> +#include "dialogs.hrc" +#include <legacysmgr/legacy_binfilters_smgr.hxx> + +namespace binfilter { +using namespace ::rtl; +using namespace ::comphelper; +using namespace ::com::sun::star; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::linguistic2; + +#define A2OU(x) OUString::createFromAscii(x) + +/////////////////////////////////////////////////////////////////////////// + + +/*N*/ static Reference< XLinguServiceManager > GetLngSvcMgr_Impl() +/*N*/ { +/*N*/ Reference< XLinguServiceManager > xRes; +/*N*/ Reference< XMultiServiceFactory > xMgr = ::legacy_binfilters::getLegacyProcessServiceFactory(); +/*N*/ if (xMgr.is()) +/*N*/ { +/*N*/ xRes = Reference< XLinguServiceManager > ( xMgr->createInstance( +/*N*/ OUString( RTL_CONSTASCII_USTRINGPARAM( +/*N*/ "com.sun.star.linguistic2.LinguServiceManager" ) ) ), UNO_QUERY ) ; +/*N*/ } +/*N*/ return xRes; +/*N*/ } + +/////////////////////////////////////////////////////////////////////////// + +// static member initialization +BOOL SvxLinguConfigUpdate::bUpdated = FALSE; + +/*N*/ void SvxLinguConfigUpdate::UpdateAll() +/*N*/ { +/*N*/ } + +/////////////////////////////////////////////////////////////////////////// + + +//! Dummy implementation in order to avoid loading of lingu DLL +//! when only the XSupportedLocales interface is used. +//! The dummy accesses the real implementation (and thus loading the DLL) +//! when "real" work needs to be done only. +/*N*/ class ThesDummy_Impl : +/*N*/ public cppu::WeakImplHelper1< XThesaurus > +/*N*/ { +/*N*/ Reference< XThesaurus > xThes; // the real one... +/*N*/ Sequence< Locale > *pLocaleSeq; +/*N*/ +/*N*/ void GetCfgLocales(); +/*N*/ +/*N*/ void GetThes_Impl(); +/*N*/ +/*N*/ public: +/*N*/ ThesDummy_Impl() : pLocaleSeq(0) {} +/*N*/ ~ThesDummy_Impl(); +/*N*/ +/*N*/ // XSupportedLocales +/*N*/ virtual ::com::sun::star::uno::Sequence< +/*N*/ ::com::sun::star::lang::Locale > SAL_CALL +/*N*/ getLocales() +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ virtual sal_Bool SAL_CALL +/*N*/ hasLocale( const ::com::sun::star::lang::Locale& rLocale ) +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ +/*N*/ // XThesaurus +/*N*/ virtual ::com::sun::star::uno::Sequence< +/*N*/ ::com::sun::star::uno::Reference< +/*N*/ ::com::sun::star::linguistic2::XMeaning > > SAL_CALL +/*N*/ queryMeanings( const ::rtl::OUString& rTerm, +/*N*/ const ::com::sun::star::lang::Locale& rLocale, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ }; + + +/*N*/ ThesDummy_Impl::~ThesDummy_Impl() +/*N*/ { +/*N*/ delete pLocaleSeq; +/*N*/ } + + +/*N*/ void ThesDummy_Impl::GetCfgLocales() +/*N*/ { +/*N*/ if (!pLocaleSeq) +/*N*/ { +/*N*/ SvtLinguConfig aCfg; +/*N*/ String aNode( A2OU( "ServiceManager/ThesaurusList" ) ); +/*N*/ Sequence < OUString > aNodeNames( aCfg.GetNodeNames( aNode ) ); +/*N*/ const OUString *pNodeNames = aNodeNames.getConstArray(); +/*N*/ INT32 nLen = aNodeNames.getLength(); +/*N*/ pLocaleSeq = new Sequence< Locale >( nLen ); +/*N*/ Locale *pLocale = pLocaleSeq->getArray(); +/*N*/ for (INT32 i = 0; i < nLen; ++i) +/*N*/ { +/*N*/ pLocale[i] = SvxCreateLocale( +/*N*/ MsLangId::convertIsoStringToLanguage( pNodeNames[i] ) ); +/*N*/ } +/*N*/ } +/*N*/ } + + +/*N*/ void ThesDummy_Impl::GetThes_Impl() +/*N*/ { +/*N*/ // update configuration before accessing the service +/*N*/ if (!SvxLinguConfigUpdate::IsUpdated()) +/*?*/ SvxLinguConfigUpdate::UpdateAll(); +/*N*/ +/*N*/ if (!xThes.is()) +/*N*/ { +/*N*/ Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() ); +/*N*/ if (xLngSvcMgr.is()) +/*N*/ xThes = xLngSvcMgr->getThesaurus(); +/*N*/ +/*?*/ if (xThes.is()) +/*?*/ { +/*?*/ // no longer needed... +/*?*/ delete pLocaleSeq; pLocaleSeq = 0; +/*?*/ } +/*N*/ } +/*N*/ } + + +/*N*/ uno::Sequence< lang::Locale > SAL_CALL +/*N*/ ThesDummy_Impl::getLocales() +/*N*/ throw(uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); uno::Sequence< lang::Locale > aa; return aa; //STRIP001 +/*N*/ } + + +/*N*/ sal_Bool SAL_CALL +/*N*/ ThesDummy_Impl::hasLocale( const lang::Locale& rLocale ) +/*N*/ throw(uno::RuntimeException) +/*N*/ { +/*N*/ if (SvxLinguConfigUpdate::IsUpdated()) +/*N*/ GetThes_Impl(); +/*N*/ if (xThes.is()) +/*?*/ return xThes->hasLocale( rLocale ); +/*N*/ else if (!pLocaleSeq) +/*N*/ GetCfgLocales(); +/*N*/ BOOL bFound = FALSE; +/*N*/ INT32 nLen = pLocaleSeq->getLength(); +/*N*/ const Locale *pLocale = pLocaleSeq->getConstArray(); +/*N*/ const Locale *pEnd = pLocale + nLen; +/*N*/ for ( ; pLocale < pEnd && !bFound; ++pLocale) +/*N*/ { +/*N*/ bFound = pLocale->Language == rLocale.Language && +/*N*/ pLocale->Country == rLocale.Country && +/*N*/ pLocale->Variant == rLocale.Variant; +/*N*/ } +/*N*/ return bFound; +/*N*/ } + + +/*N*/ uno::Sequence< uno::Reference< linguistic2::XMeaning > > SAL_CALL +/*N*/ ThesDummy_Impl::queryMeanings( +/*N*/ const ::rtl::OUString& rTerm, +/*N*/ const lang::Locale& rLocale, +/*N*/ const beans::PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); uno::Sequence< uno::Reference< linguistic2::XMeaning > > aRes;return aRes; //STRIP001 +/*N*/ } + + +/////////////////////////////////////////////////////////////////////////// + + +//! Dummy implementation in order to avoid loading of lingu DLL. +//! The dummy accesses the real implementation (and thus loading the DLL) +//! when it needs to be done only. +/*N*/ class SpellDummy_Impl : +/*N*/ public cppu::WeakImplHelper1< XSpellChecker1 > +/*N*/ { +/*N*/ Reference< XSpellChecker1 > xSpell; // the real one... +/*N*/ +/*N*/ void GetSpell_Impl(); +/*N*/ +/*N*/ public: +/*N*/ +/*N*/ // XSupportedLanguages (for XSpellChecker1) +/*N*/ virtual ::com::sun::star::uno::Sequence< sal_Int16 > SAL_CALL +/*N*/ getLanguages() +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ virtual sal_Bool SAL_CALL +/*N*/ hasLanguage( sal_Int16 nLanguage ) +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ +/*N*/ // XSpellChecker1 (same as XSpellChecker but sal_Int16 for language) +/*N*/ virtual sal_Bool SAL_CALL +/*N*/ isValid( const ::rtl::OUString& rWord, sal_Int16 nLanguage, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ virtual ::com::sun::star::uno::Reference< +/*N*/ ::com::sun::star::linguistic2::XSpellAlternatives > SAL_CALL +/*N*/ spell( const ::rtl::OUString& rWord, sal_Int16 nLanguage, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ }; + + +/*N*/ void SpellDummy_Impl::GetSpell_Impl() +/*N*/ { DBG_BF_ASSERT(0, "STRIP"); //STRIP001 +/*N*/ } + + +/*N*/ uno::Sequence< sal_Int16 > SAL_CALL +/*N*/ SpellDummy_Impl::getLanguages() +/*N*/ throw(uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Sequence< sal_Int16 >(); //STRIP001 +/*N*/ } + + +/*N*/ sal_Bool SAL_CALL +/*N*/ SpellDummy_Impl::hasLanguage( sal_Int16 nLanguage ) +/*N*/ throw(uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP");return FALSE; //STRIP001 +/*N*/ } + + +/*N*/ sal_Bool SAL_CALL +/*N*/ SpellDummy_Impl::isValid( const ::rtl::OUString& rWord, sal_Int16 nLanguage, +/*N*/ const beans::PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*?*/ GetSpell_Impl(); +/*?*/ BOOL bRes = TRUE; +/*?*/ if (xSpell.is()) +/*?*/ bRes = xSpell->isValid( rWord, nLanguage, rProperties ); +/*?*/ return bRes; +/*N*/ } + + +/*N*/ uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL +/*N*/ SpellDummy_Impl::spell( const ::rtl::OUString& rWord, sal_Int16 nLanguage, +/*N*/ const beans::PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); uno::Reference< linguistic2::XSpellAlternatives > xRes; return xRes; //STRIP001 +/*N*/ } + + +/////////////////////////////////////////////////////////////////////////// + + +//! Dummy implementation in order to avoid loading of lingu DLL. +//! The dummy accesses the real implementation (and thus loading the DLL) +//! when it needs to be done only. +/*N*/ class HyphDummy_Impl : +/*N*/ public cppu::WeakImplHelper1< XHyphenator > +/*N*/ { +/*N*/ Reference< XHyphenator > xHyph; // the real one... +/*N*/ +/*N*/ void GetHyph_Impl(); +/*N*/ +/*N*/ public: +/*N*/ +/*N*/ // XSupportedLocales +/*N*/ virtual ::com::sun::star::uno::Sequence< +/*N*/ ::com::sun::star::lang::Locale > SAL_CALL +/*N*/ getLocales() +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ virtual sal_Bool SAL_CALL +/*N*/ hasLocale( const ::com::sun::star::lang::Locale& rLocale ) +/*N*/ throw(::com::sun::star::uno::RuntimeException); +/*N*/ +/*N*/ // XHyphenator +/*N*/ virtual ::com::sun::star::uno::Reference< +/*N*/ ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL +/*N*/ hyphenate( const ::rtl::OUString& rWord, +/*N*/ const ::com::sun::star::lang::Locale& rLocale, +/*N*/ sal_Int16 nMaxLeading, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ virtual ::com::sun::star::uno::Reference< +/*N*/ ::com::sun::star::linguistic2::XHyphenatedWord > SAL_CALL +/*N*/ queryAlternativeSpelling( const ::rtl::OUString& rWord, +/*N*/ const ::com::sun::star::lang::Locale& rLocale, +/*N*/ sal_Int16 nIndex, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ virtual ::com::sun::star::uno::Reference< +/*N*/ ::com::sun::star::linguistic2::XPossibleHyphens > SAL_CALL +/*N*/ createPossibleHyphens( +/*N*/ const ::rtl::OUString& rWord, +/*N*/ const ::com::sun::star::lang::Locale& rLocale, +/*N*/ const ::com::sun::star::beans::PropertyValues& rProperties ) +/*N*/ throw(::com::sun::star::lang::IllegalArgumentException, +/*N*/ ::com::sun::star::uno::RuntimeException); +/*N*/ }; + + +/*N*/ void HyphDummy_Impl::GetHyph_Impl() +/*N*/ { +/*N*/ // update configuration before accessing the service +/*N*/ if (!SvxLinguConfigUpdate::IsUpdated()) +/*N*/ SvxLinguConfigUpdate::UpdateAll(); +/*N*/ +/*N*/ if (!xHyph.is()) +/*N*/ { +/*N*/ Reference< XLinguServiceManager > xLngSvcMgr( GetLngSvcMgr_Impl() ); +/*N*/ if (xLngSvcMgr.is()) +/*N*/ xHyph = xLngSvcMgr->getHyphenator(); +/*N*/ } +/*N*/ } + + +/*N*/ uno::Sequence< lang::Locale > SAL_CALL +/*N*/ HyphDummy_Impl::getLocales() +/*N*/ throw(uno::RuntimeException) +/*N*/ {DBG_BF_ASSERT(0, "STRIP"); return uno::Sequence< lang::Locale >();//STRIP001 +/*N*/ } + + +/*N*/ sal_Bool SAL_CALL +/*N*/ HyphDummy_Impl::hasLocale( const lang::Locale& rLocale ) +/*N*/ throw(uno::RuntimeException) +/*N*/ { +/*N*/ GetHyph_Impl(); +/*N*/ BOOL bRes = FALSE; +/*N*/ if (xHyph.is()) +/*N*/ bRes = xHyph->hasLocale( rLocale ); +/*N*/ return bRes; +/*N*/ } + + +/*N*/ uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL +/*N*/ HyphDummy_Impl::hyphenate( +/*N*/ const ::rtl::OUString& rWord, +/*N*/ const lang::Locale& rLocale, +/*N*/ sal_Int16 nMaxLeading, +/*N*/ const beans::PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ GetHyph_Impl(); +/*N*/ uno::Reference< linguistic2::XHyphenatedWord > xRes; +/*N*/ if (xHyph.is()) +/*N*/ xRes = xHyph->hyphenate( rWord, rLocale, nMaxLeading, rProperties ); +/*N*/ return xRes; +/*N*/ } + + +/*N*/ uno::Reference< linguistic2::XHyphenatedWord > SAL_CALL +/*N*/ HyphDummy_Impl::queryAlternativeSpelling( +/*N*/ const ::rtl::OUString& rWord, +/*N*/ const lang::Locale& rLocale, +/*N*/ sal_Int16 nIndex, +/*N*/ const PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*N*/ GetHyph_Impl(); +/*N*/ uno::Reference< linguistic2::XHyphenatedWord > xRes; +/*N*/ if (xHyph.is()) +/*N*/ xRes = xHyph->queryAlternativeSpelling( rWord, rLocale, nIndex, rProperties ); +/*N*/ return xRes; +/*N*/ } + + +/*N*/ uno::Reference< linguistic2::XPossibleHyphens > SAL_CALL +/*N*/ HyphDummy_Impl::createPossibleHyphens( +/*N*/ const ::rtl::OUString& rWord, +/*N*/ const lang::Locale& rLocale, +/*N*/ const beans::PropertyValues& rProperties ) +/*N*/ throw(lang::IllegalArgumentException, +/*N*/ uno::RuntimeException) +/*N*/ { +/*?*/ GetHyph_Impl(); +/*?*/ uno::Reference< linguistic2::XPossibleHyphens > xRes; +/*?*/ if (xHyph.is()) +/*?*/ xRes = xHyph->createPossibleHyphens( rWord, rLocale, rProperties ); +/*?*/ return xRes; +/*N*/ } + + +/////////////////////////////////////////////////////////////////////////// + + +/*N*/ typedef cppu::WeakImplHelper1 < XEventListener > LinguMgrAppExitLstnrBaseClass; + +/*N*/ class LinguMgrAppExitLstnr : public LinguMgrAppExitLstnrBaseClass +/*N*/ { +/*N*/ Reference< XComponent > xDesktop; +/*N*/ +/*N*/ public: +/*N*/ LinguMgrAppExitLstnr(); +/*N*/ virtual ~LinguMgrAppExitLstnr(); +/*N*/ +/*N*/ virtual void AtExit() = 0; +/*N*/ +/*N*/ +/*N*/ // lang::XEventListener +/*N*/ virtual void SAL_CALL disposing(const EventObject& rSource) +/*N*/ throw( RuntimeException ); +/*N*/ }; + +/*N*/ LinguMgrAppExitLstnr::LinguMgrAppExitLstnr() +/*N*/ { +/*N*/ // add object to frame::Desktop EventListeners in order to properly call +/*N*/ // the AtExit function at appliction exit. +/*N*/ +/*N*/ Reference< XMultiServiceFactory > xMgr = ::legacy_binfilters::getLegacyProcessServiceFactory(); +/*N*/ if ( xMgr.is() ) +/*N*/ { +/*N*/ xDesktop = Reference< XComponent > ( xMgr->createInstance( +/*N*/ OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) ) ), UNO_QUERY ) ; +/*N*/ if (xDesktop.is()) +/*N*/ xDesktop->addEventListener( this ); +/*N*/ } +/*N*/ } + +/*N*/ LinguMgrAppExitLstnr::~LinguMgrAppExitLstnr() +/*N*/ { +/*N*/ if (xDesktop.is()) +/*N*/ { +/*?*/ xDesktop->removeEventListener( this ); +/*?*/ xDesktop = NULL; //! release reference to desktop +/*N*/ } +/*N*/ DBG_ASSERT(!xDesktop.is(), "reference to desktop should be realeased"); +/*N*/ } + +/*N*/ void LinguMgrAppExitLstnr::disposing(const EventObject& rSource) +/*N*/ throw( RuntimeException ) +/*N*/ { +/*N*/ if (xDesktop.is() && rSource.Source == xDesktop) +/*N*/ { +/*N*/ xDesktop->removeEventListener( this ); +/*N*/ xDesktop = NULL; //! release reference to desktop +/*N*/ +/*N*/ AtExit(); +/*N*/ } +/*N*/ } + +/////////////////////////////////////////////////////////////////////////// + +/*N*/ class LinguMgrExitLstnr : public LinguMgrAppExitLstnr +/*N*/ { +/*N*/ public: +/*N*/ virtual void AtExit(); +/*N*/ }; + +/*N*/ void LinguMgrExitLstnr::AtExit() +/*N*/ { +/*N*/ // release references +/*N*/ LinguMgr::xLngSvcMgr = 0; +/*N*/ LinguMgr::xSpell = 0; +/*N*/ LinguMgr::xHyph = 0; +/*N*/ LinguMgr::xThes = 0; +/*N*/ LinguMgr::xDicList = 0; +/*N*/ LinguMgr::xProp = 0; +/*N*/ LinguMgr::xIgnoreAll = 0; +/*N*/ LinguMgr::xChangeAll = 0; +/*N*/ +/*N*/ LinguMgr::bExiting = sal_True; +/*N*/ +/*N*/ //TL:TODO: MBA fragen wie ich ohne Absturz hier meinen Speicher +/*N*/ // wieder freibekomme... +/*N*/ //delete LinguMgr::pExitLstnr; +/*N*/ LinguMgr::pExitLstnr = 0; +/*N*/ } + +/////////////////////////////////////////////////////////////////////////// + + +// static member initialization +/*N*/ LinguMgrExitLstnr * LinguMgr::pExitLstnr = 0; +/*N*/ sal_Bool LinguMgr::bExiting = sal_False; +/*N*/ Reference< XLinguServiceManager > LinguMgr::xLngSvcMgr = 0; +/*N*/ Reference< XSpellChecker1 > LinguMgr::xSpell = 0; +/*N*/ Reference< XHyphenator > LinguMgr::xHyph = 0; +/*N*/ Reference< XThesaurus > LinguMgr::xThes = 0; +/*N*/ Reference< XDictionaryList > LinguMgr::xDicList = 0; +/*N*/ Reference< XPropertySet > LinguMgr::xProp = 0; +/*N*/ Reference< XDictionary1 > LinguMgr::xIgnoreAll = 0; +/*N*/ Reference< XDictionary1 > LinguMgr::xChangeAll = 0; + +/*N*/ Reference< XHyphenator > LinguMgr::GetHyphenator() +/*N*/ { +/*N*/ return xHyph.is() ? xHyph : GetHyph(); +/*N*/ } + +/*N*/ Reference< XDictionaryList > LinguMgr::GetDictionaryList() +/*N*/ { +/*N*/ return xDicList.is() ? xDicList : GetDicList(); +/*N*/ } + +/*N*/ Reference< XHyphenator > LinguMgr::GetHyph() +/*N*/ { +/*N*/ if (bExiting) +/*N*/ return 0; +/*N*/ +/*N*/ if (!pExitLstnr) +/*N*/ pExitLstnr = new LinguMgrExitLstnr; +/*N*/ +/*N*/ //! use dummy implementation in order to avoid loading of lingu DLL +/*N*/ xHyph = new HyphDummy_Impl; +/*N*/ +/* + if (!xLngSvcMgr.is()) + xLngSvcMgr = GetLngSvcMgr_Impl(); + + if (xLngSvcMgr.is()) + { + xHyph = xLngSvcMgr->getHyphenator(); + } +*/ +/*N*/ return xHyph; +/*N*/ } + +/*N*/ Reference< XDictionaryList > LinguMgr::GetDicList() +/*N*/ { +/*N*/ if (bExiting) +/*N*/ return 0; +/*N*/ +/*N*/ if (!pExitLstnr) +/*N*/ pExitLstnr = new LinguMgrExitLstnr; +/*N*/ +/*N*/ Reference< XMultiServiceFactory > xMgr( ::legacy_binfilters::getLegacyProcessServiceFactory() ); +/*N*/ if (xMgr.is()) +/*N*/ { +/*N*/ xDicList = Reference< XDictionaryList > ( xMgr->createInstance( +/*N*/ A2OU("com.sun.star.linguistic2.DictionaryList") ), UNO_QUERY ); +/*N*/ } +/*N*/ return xDicList; +/*N*/ } + + + + + +/////////////////////////////////////////////////////////////////////////// + + + + + + +//TL:TODO: remove argument or provide SvxGetIgnoreAllList with the same one + + + +/////////////////////////////////////////////////////////////////////////// + + +#include <com/sun/star/linguistic2/XHyphenatedWord.hpp> + + + +/////////////////////////////////////////////////////////////////////////// + + + +/////////////////////////////////////////////////////////////////////////// + + +//TL:TODO: soll mal den rictigen Rckgabetyp bekommen! + + + +/*N*/ LanguageType SvxLocaleToLanguage( const Locale& rLocale ) +/*N*/ { +/*N*/ // empty Locale -> LANGUAGE_NONE +/*N*/ if ( rLocale.Language.getLength() == 0 ) +/*N*/ return LANGUAGE_NONE; +/*N*/ +/*N*/ return MsLangId::convertLocaleToLanguage( rLocale ); +/*N*/ } + +/*N*/ Locale& SvxLanguageToLocale( Locale& rLocale, LanguageType eLang ) +/*N*/ { +/*N*/ if ( eLang != LANGUAGE_NONE /* && eLang != LANGUAGE_SYSTEM */) +/*N*/ MsLangId::convertLanguageToLocale( eLang, rLocale ); +/*N*/ else +/*N*/ rLocale = Locale(); +/*N*/ +/*N*/ return rLocale; +/*N*/ } + +/*N*/ Locale SvxCreateLocale( LanguageType eLang ) +/*N*/ { +/*N*/ Locale aLocale; +/*N*/ if ( eLang != LANGUAGE_NONE /* && eLang != LANGUAGE_SYSTEM */) +/*N*/ MsLangId::convertLanguageToLocale( eLang, aLocale ); +/*N*/ +/*N*/ return aLocale; +/*N*/ } + + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |