diff options
Diffstat (limited to 'sw/source/core/unocore/unoparagraph.cxx')
-rw-r--r-- | sw/source/core/unocore/unoparagraph.cxx | 281 |
1 files changed, 226 insertions, 55 deletions
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index c7968ce65fa6..9df686af04b7 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -19,8 +19,6 @@ * *************************************************************/ - - // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" @@ -52,11 +50,17 @@ #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/TextContentAnchorType.hpp> +//UUUU +#include <swunohelper.hxx> +#include <svx/unobrushitemhelper.hxx> +#include <editeng/unoipset.hxx> +#include <svx/xflbstit.hxx> +#include <svx/xflbmtit.hxx> +#include <com/sun/star/drawing/BitmapMode.hpp> using namespace ::com::sun::star; using ::rtl::OUString; - /* -----------------------------01.12.00 18:09-------------------------------- ---------------------------------------------------------------------------*/ @@ -174,6 +178,13 @@ public: throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + //UUUU + void GetSinglePropertyValue_Impl( + const SfxItemPropertySimpleEntry& rEntry, + const SfxItemSet& rSet, + uno::Any& rAny ) const + throw(uno::RuntimeException); + uno::Sequence< beans::GetDirectPropertyTolerantResult > GetPropertyValuesTolerant_Impl( const uno::Sequence< ::rtl::OUString >& rPropertyNames, @@ -481,6 +492,99 @@ throw (beans::PropertyVetoException, lang::IllegalArgumentException, /* -----------------------------02.04.01 11:43-------------------------------- ---------------------------------------------------------------------------*/ + +//UUUU Support for DrawingLayer FillStyles for GetPropertyValue() usages +void SwXParagraph::Impl::GetSinglePropertyValue_Impl( + const SfxItemPropertySimpleEntry& rEntry, + const SfxItemSet& rSet, + uno::Any& rAny ) const +throw(uno::RuntimeException) +{ + bool bDone(false); + + switch(rEntry.nWID) + { + case RES_BACKGROUND: + { + const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND)); + const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); + + if(!aOriginalBrushItem.QueryValue(rAny, nMemberId)) + { + OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); + } + + bDone = true; + break; + } + case OWN_ATTR_FILLBMP_MODE: + { + const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH)); + const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE)); + + if( pTileItem && pTileItem->GetValue() ) + { + rAny <<= drawing::BitmapMode_REPEAT; + } + else if( pStretchItem && pStretchItem->GetValue() ) + { + rAny <<= drawing::BitmapMode_STRETCH; + } + else + { + rAny <<= drawing::BitmapMode_NO_REPEAT; + } + + bDone = true; + break; + } + default: break; + } + + if(!bDone) + { + // fallback to standard get value implementation used before this helper was created + m_rPropSet.getPropertyValue(rEntry, rSet, rAny); + + if(rEntry.pType && *(rEntry.pType) == ::getCppuType((const sal_Int16*)0) && *(rEntry.pType) != rAny.getValueType()) + { + // since the sfx uInt16 item now exports a sal_Int32, we may have to fix this here + sal_Int32 nValue(0); + + rAny >>= nValue; + rAny <<= static_cast< sal_Int16 >(nValue); + } + + //UUUU check for needed metric translation + if(rEntry.nMemberId & SFX_METRIC_ITEM) + { + bool bDoIt(true); + + if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID) + { + // exception: If these ItemTypes are used, do not convert when these are negative + // since this means they are intended as percent values + sal_Int32 nValue = 0; + + if(rAny >>= nValue) + { + bDoIt = nValue > 0; + } + } + + if(bDoIt) + { + const SfxMapUnit eMapUnit(rSet.GetPool()->GetMetric(rEntry.nWID)); + + if(eMapUnit != SFX_MAPUNIT_100TH_MM) + { + SvxUnoConvertToMM(eMapUnit, rAny); + } + } + } + } +} + uno::Sequence< uno::Any > SwXParagraph::Impl::GetPropertyValues_Impl( const uno::Sequence< OUString > & rPropertyNames ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, @@ -514,8 +618,8 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, *pEntry, aPam, &(pValues[nProp]), eTemp, &rTxtNode ); if (!bDone) { - m_rPropSet.getPropertyValue( - *pEntry, rAttrSet, pValues[nProp]); + //UUUU + GetSinglePropertyValue_Impl(*pEntry, rAttrSet, pValues[nProp]); } } } @@ -797,8 +901,8 @@ throw (uno::RuntimeException) // if not found try the real paragraph attributes... if (!bDone) { - m_rPropSet.getPropertyValue( - *pEntry, rValueAttrSet, aValue ); + //UUUU + GetSinglePropertyValue_Impl(*pEntry, rValueAttrSet, aValue); } } @@ -931,61 +1035,107 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, //----------------------------------------------------------------------------- beans::PropertyState lcl_SwXParagraph_getPropertyState( -// SwUnoCrsr& rUnoCrsr, - const SwTxtNode& rTxtNode, - const SwAttrSet** ppSet, - const SfxItemPropertySimpleEntry& rEntry, - sal_Bool &rAttrSetFetched ) -throw (beans::UnknownPropertyException) + // SwUnoCrsr& rUnoCrsr, + const SwTxtNode& rTxtNode, + const SwAttrSet** ppSet, + const SfxItemPropertySimpleEntry& rEntry, + sal_Bool &rAttrSetFetched) + throw (beans::UnknownPropertyException) { - beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; + beans::PropertyState eRet(beans::PropertyState_DEFAULT_VALUE); - if(!(*ppSet) && !rAttrSetFetched ) + if(!(*ppSet) && !rAttrSetFetched) { (*ppSet) = rTxtNode.GetpSwAttrSet(); rAttrSetFetched = sal_True; } - SwPosition aPos( rTxtNode ); - SwPaM aPam( aPos ); - switch( rEntry.nWID ) + + SwPosition aPos(rTxtNode); + SwPaM aPam(aPos); + bool bDone(false); + + switch(rEntry.nWID) { - case FN_UNO_NUM_RULES: - // if numbering is set, return it; else do nothing - SwUnoCursorHelper::getNumberingProperty( aPam, eRet, NULL ); - break; - case FN_UNO_ANCHOR_TYPES: - break; - case RES_ANCHOR: - if ( MID_SURROUND_SURROUNDTYPE != rEntry.nMemberId ) - goto lcl_SwXParagraph_getPropertyStateDEFAULT; - break; - case RES_SURROUND: - if ( MID_ANCHOR_ANCHORTYPE != rEntry.nMemberId ) - goto lcl_SwXParagraph_getPropertyStateDEFAULT; - break; - case FN_UNO_PARA_STYLE: - case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: + case FN_UNO_NUM_RULES: { - SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl( - aPam, rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); - eRet = pFmt ? beans::PropertyState_DIRECT_VALUE - : beans::PropertyState_AMBIGUOUS_VALUE; + // if numbering is set, return it; else do nothing + SwUnoCursorHelper::getNumberingProperty(aPam,eRet,NULL); + bDone = true; + break; } - break; - case FN_UNO_PAGE_STYLE: + case FN_UNO_ANCHOR_TYPES: + { + bDone = true; + break; + } + case RES_ANCHOR: + { + bDone = (MID_SURROUND_SURROUNDTYPE == rEntry.nMemberId); + break; + } + case RES_SURROUND: + { + bDone = (MID_ANCHOR_ANCHORTYPE == rEntry.nMemberId); + break; + } + case FN_UNO_PARA_STYLE: + case FN_UNO_PARA_CONDITIONAL_STYLE_NAME: + { + SwFmtColl* pFmt = SwUnoCursorHelper::GetCurTxtFmtColl(aPam,rEntry.nWID == FN_UNO_PARA_CONDITIONAL_STYLE_NAME); + eRet = pFmt ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; + bDone = true; + break; + } + case FN_UNO_PAGE_STYLE: { String sVal; - SwUnoCursorHelper::GetCurPageStyle( aPam, sVal ); - eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE - : beans::PropertyState_AMBIGUOUS_VALUE; + SwUnoCursorHelper::GetCurPageStyle(aPam,sVal); + eRet = sVal.Len() ? beans::PropertyState_DIRECT_VALUE : beans::PropertyState_AMBIGUOUS_VALUE; + bDone = true; + break; } - break; - lcl_SwXParagraph_getPropertyStateDEFAULT: - default: - if((*ppSet) && SFX_ITEM_SET == (*ppSet)->GetItemState(rEntry.nWID, sal_False)) + + //UUUU DrawingLayer PropertyStyle support + case OWN_ATTR_FILLBMP_MODE: + { + if(*ppSet) + { + if(SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_STRETCH, false) + || SFX_ITEM_SET == (*ppSet)->GetItemState(XATTR_FILLBMP_TILE, false)) + { + eRet = beans::PropertyState_DIRECT_VALUE; + } + else + { + eRet = beans::PropertyState_AMBIGUOUS_VALUE; + } + + bDone = true; + } + break; + } + case RES_BACKGROUND: + { + if(*ppSet) + { + if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet)) + { + eRet = beans::PropertyState_DIRECT_VALUE; + bDone = true; + } + } + break; + } + } + + if(!bDone) + { + if((*ppSet) && SFX_ITEM_SET == (*ppSet)->GetItemState(rEntry.nWID,sal_False)) + { eRet = beans::PropertyState_DIRECT_VALUE; - break; + } } + return eRet; } @@ -1102,10 +1252,24 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) static_cast<cppu::OWeakObject *>(this)); } - if (pEntry->nWID < RES_FRMATR_END) + const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END); + const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID); + + if(bBelowFrmAtrEnd || bDrawingLayerRange) { SvUShortsSort aWhichIds; - aWhichIds.Insert(pEntry->nWID); + + //UUUU For FillBitmapMode two IDs have to be reset (!) + if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) + { + aWhichIds.Insert(XATTR_FILLBMP_STRETCH); + aWhichIds.Insert(XATTR_FILLBMP_TILE); + } + else + { + aWhichIds.Insert(pEntry->nWID); + } + if (pEntry->nWID < RES_PARATR_BEGIN) { aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds); @@ -1116,20 +1280,24 @@ throw (beans::UnknownPropertyException, uno::RuntimeException) // to paragraph boundaries SwPosition aStart( *aCursor.Start() ); SwPosition aEnd ( *aCursor.End() ); - ::std::auto_ptr<SwUnoCrsr> pTemp( - aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); + ::std::auto_ptr<SwUnoCrsr> pTemp( aCursor.GetDoc()->CreateUnoCrsr(aStart, sal_False) ); + if(!SwUnoCursorHelper::IsStartOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaStart); } + pTemp->SetMark(); *pTemp->GetPoint() = aEnd; //pTemp->Exchange(); + SwUnoCursorHelper::SelectPam(*pTemp, true); + if (!SwUnoCursorHelper::IsEndOfPara(*pTemp)) { pTemp->MovePara(fnParaCurr, fnParaEnd); } + pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds); } } @@ -1167,10 +1335,13 @@ throw (beans::UnknownPropertyException, lang::WrappedTargetException, static_cast<cppu::OWeakObject *>(this)); } - if (pEntry->nWID < RES_FRMATR_END) + const bool bBelowFrmAtrEnd(pEntry->nWID < RES_FRMATR_END); + const bool bDrawingLayerRange(XATTR_FILL_FIRST <= pEntry->nWID && XATTR_FILL_LAST >= pEntry->nWID); + + if(bBelowFrmAtrEnd || bDrawingLayerRange) { - const SfxPoolItem& rDefItem = - rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + const SfxPoolItem& rDefItem = rTxtNode.GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); + rDefItem.QueryValue(aRet, pEntry->nMemberId); } |