diff options
author | Thomas Lange <tl@openoffice.org> | 2001-03-29 07:02:02 +0000 |
---|---|---|
committer | Thomas Lange <tl@openoffice.org> | 2001-03-29 07:02:02 +0000 |
commit | 9dd8158c01e31e1992752e3ea1dec59abd9d2f86 (patch) | |
tree | d8bbf7346b0788ab7bd9d9f98ae49fa323fc0e7c | |
parent | 23de1acc3be57617695a4543d4279b9d122d530a (diff) |
#84966 GetHyphValues added; RestoreHyphOptions, IsRestoreHyphOptions removed
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 105 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.hxx | 16 |
2 files changed, 67 insertions, 54 deletions
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 51bce81569ac..42b1eed8fad2 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -2,9 +2,9 @@ * * $RCSfile: inftxt.cxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.28 $ * - * last change: $Author: ama $ $Date: 2001-03-20 08:21:51 $ + * last change: $Author: tl $ $Date: 2001-03-29 08:02:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,6 +65,12 @@ #pragma hdrstop +#include <com/sun/star/uno/Sequence.h> + +#ifndef _SVTOOLS_LINGUPROPS_HXX_ +#include <svtools/linguprops.hxx> +#endif + #ifndef _HINTIDS_HXX #include <hintids.hxx> #endif @@ -175,6 +181,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::linguistic2; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; #define C2U(cChar) rtl::OUString::createFromAscii(cChar) #define DARK_COLOR 154 @@ -790,6 +798,49 @@ void SwTxtPaintInfo::_NotifyURL( const SwLinePortion &rPor ) const } /************************************************************************* + * lcl_InitHyphValues() + *************************************************************************/ + +static lcl_InitHyphValues( PropertyValues &rVals, + INT16 nMinLeading, INT16 nMinTrailing ) +{ + INT32 nLen = rVals.getLength(); + + if (0 == nLen) // yet to be initialized? + { + rVals.realloc( 2 ); + PropertyValue *pVal = rVals.getArray(); + + pVal[0].Name = C2U( UPN_HYPH_MIN_LEADING ); + pVal[0].Handle = UPH_HYPH_MIN_LEADING; + pVal[0].Value <<= nMinLeading; + + pVal[1].Name = C2U( UPN_HYPH_MIN_TRAILING ); + pVal[1].Handle = UPH_HYPH_MIN_TRAILING; + pVal[1].Value <<= nMinTrailing; + } + else if (2 == nLen) // already initialized once? + { + PropertyValue *pVal = rVals.getArray(); + pVal[0].Value <<= nMinLeading; + pVal[1].Value <<= nMinTrailing; + } + else + DBG_ERROR( "unxpected size of sequence" ); +} + +/************************************************************************* + * SwTxtFormatInfo::GetHyphValues() + *************************************************************************/ + +const PropertyValues & SwTxtFormatInfo::GetHyphValues() const +{ + DBG_ASSERT( 2 == aHyphVals.getLength(), + "hyphenation values not yet initialized" ); + return aHyphVals; +} + +/************************************************************************* * SwTxtFormatInfo::InitHyph() *************************************************************************/ @@ -804,57 +855,15 @@ sal_Bool SwTxtFormatInfo::InitHyph( const sal_Bool bAutoHyph ) sal_Bool bAuto = bAutoHyph || rAttr.IsHyphen(); if( bAuto || bInterHyph ) { - uno::Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() ); nHyphStart = nHyphWrdStart = STRING_LEN; nHyphWrdLen = 0; - // save hyphenation relevant Lingu properties for later restoration - // before changing them - if( xProp.is() && !bRestoreHyphOptions ) - { - // paraex.hxx zeigt, dass im Attribut nMinLead = nMinTrail = 0 - // initialisiert wird. - - sal_Int16 nTemp; - xProp->getPropertyValue( C2U(UPN_HYPH_MIN_LEADING) ) >>= nTemp; - nMinLeading = nTemp; - xProp->getPropertyValue( C2U(UPN_HYPH_MIN_LEADING) ) >>= nTemp; - nMinTrailing = nTemp; - // nMinWordLength = ; noch nicht am Absatz verwendet - INT16 nNewMinLeading = Max(rAttr.GetMinLead(), sal_uInt8(2)); - INT16 nNewMinTrailing = rAttr.GetMinTrail(); - bRestoreHyphOptions = (nMinLeading != nNewMinLeading) || - (nMinTrailing != nNewMinTrailing); - - if (bRestoreHyphOptions) - { - uno::Any aTemp; - aTemp <<= nNewMinLeading; - xProp->setPropertyValue( C2U(UPN_HYPH_MIN_LEADING), aTemp ); - aTemp <<= nNewMinTrailing; - xProp->setPropertyValue( C2U(UPN_HYPH_MIN_TRAILING), aTemp ); - } - } + INT16 nMinLeading = Max(rAttr.GetMinLead(), sal_uInt8(2)); + INT16 nMinTrailing = rAttr.GetMinTrail(); + lcl_InitHyphValues( aHyphVals, nMinLeading, nMinTrailing); } return bAuto; } -/************************************************************************* - * SwTxtFormatInfo::RestoreHyphOptions() - *************************************************************************/ - -void SwTxtFormatInfo::RestoreHyphOptions() -{ - uno::Reference< beans::XPropertySet > xProp( ::GetLinguPropertySet() ); - if (xProp.is()) - { - uno::Any aVal; - aVal <<= (sal_Int16)nMinLeading; - xProp->setPropertyValue( C2U(UPN_HYPH_MIN_LEADING), aVal ); - aVal <<= (sal_Int16)nMinTrailing; - xProp->setPropertyValue( C2U(UPN_HYPH_MIN_TRAILING), aVal ); - //xProp->setPropertyValue( C2U(UPN_HYPH_MIN_WORDLENGTH), ); - } -} /************************************************************************* * SwTxtFormatInfo::CtorInit() @@ -873,7 +882,6 @@ void SwTxtFormatInfo::CtorInit( SwTxtFrm *pNewFrm, const sal_Bool bNewInterHyph, nMinLeading = 2; nMinTrailing = 2; nMinWordLength = 0; - bRestoreHyphOptions = sal_False; bAutoHyph = InitHyph(); bIgnoreFly = sal_False; @@ -995,7 +1003,6 @@ SwTxtFormatInfo::SwTxtFormatInfo( const SwTxtFormatInfo& rInf, nMinLeading = 0; nMinTrailing = 0; nMinWordLength = 0; - bRestoreHyphOptions = FALSE; bFull = FALSE; bFtnDone = TRUE; bErgoDone = TRUE; diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 3de48c3b7043..d6713796248d 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -2,9 +2,9 @@ * * $RCSfile: inftxt.hxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: ama $ $Date: 2001-03-13 09:54:20 $ + * last change: $Author: tl $ $Date: 2001-03-29 08:00:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,6 +62,9 @@ #define _INFTXT_HXX #include <com/sun/star/linguistic2/XHyphenatedWord.hpp> +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif #include "swtypes.hxx" #include "txttypes.hxx" @@ -432,6 +435,9 @@ public: class SwTxtFormatInfo : public SwTxtPaintInfo { + // temporary arguments for hyphenation + com::sun::star::beans::PropertyValues aHyphVals; + SwLineLayout *pRoot; // die Root der aktuellen Zeile (pCurr) SwLinePortion *pLast; // die letzte Portion SwFlyPortion *pFly; // die nachfolgende FlyPortion @@ -457,7 +463,7 @@ class SwTxtFormatInfo : public SwTxtPaintInfo INT16 nMinLeading; // minimum number of chars before hyphenation point INT16 nMinTrailing; // minimum number of chars after hyphenation point INT16 nMinWordLength; // minimum length of word to be hyphenated - sal_Bool bRestoreHyphOptions : 1; + sal_Bool bFull : 1; // Zeile ist voll sal_Bool bFtnDone : 1; // Ftn bereits formatiert sal_Bool bErgoDone : 1; // ErgoDone bereits formatiert @@ -612,12 +618,12 @@ public: inline void SetHyphWrdLen( const xub_StrLen nNew ) { nHyphWrdLen = nNew; } inline xub_StrLen GetHyphWrdLen() const { return nHyphWrdLen; } - inline sal_Bool IsRestoreHyphOptions() const { return bRestoreHyphOptions; } - void RestoreHyphOptions(); // ruft HyphenateWord() des Hyphenators ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenatedWord > HyphWord( const String &rTxt, const USHORT nMinTrail ); + const com::sun::star::beans::PropertyValues & + GetHyphValues() const; sal_Bool CheckFtnPortion( SwLineLayout* pCurr ) { return IsFtnInside() && _CheckFtnPortion( pCurr ); } |