diff options
Diffstat (limited to 'svx/source/svdraw')
-rw-r--r-- | svx/source/svdraw/selectioncontroller.cxx | 11 | ||||
-rw-r--r-- | svx/source/svdraw/svdedxv.cxx | 226 | ||||
-rw-r--r-- | svx/source/svdraw/svdotextdecomposition.cxx | 48 | ||||
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 8 |
4 files changed, 275 insertions, 18 deletions
diff --git a/svx/source/svdraw/selectioncontroller.cxx b/svx/source/svdraw/selectioncontroller.cxx index 0c954e4a9e10..ed25ae0e1ffe 100644 --- a/svx/source/svdraw/selectioncontroller.cxx +++ b/svx/source/svdraw/selectioncontroller.cxx @@ -31,6 +31,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" +#include <tools/debug.hxx> #include <svx/selectioncontroller.hxx> namespace sdr @@ -103,4 +104,14 @@ bool SelectionController::PasteObjModel( const SdrModel& /*rModel*/ ) return false; } +bool SelectionController::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& /*rFormatSet*/ ) +{ + return false; +} + +bool SelectionController::ApplyFormatPaintBrush( SfxItemSet& /*rFormatSet*/, bool /*bNoCharacterFormats*/, bool /*bNoParagraphFormats*/ ) +{ + return false; +} + } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index fb9670a5d4b4..e3d2f3390201 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -30,6 +30,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" + +#include <com/sun/star/i18n/WordType.hpp> + #include <svtools/accessibilityoptions.hxx> #include <svx/svdedxv.hxx> @@ -46,6 +49,7 @@ #include <vcl/cursor.hxx> #include <svx/unotext.hxx> +#include <svx/editeng.hxx> #include <svx/editobj.hxx> #include <svx/outlobj.hxx> #include <svx/scripttypeitem.hxx> @@ -60,7 +64,6 @@ #include "svx/svdetc.hxx" // fuer GetDraftFillColor #include "svx/svdotable.hxx" #include <svx/selectioncontroller.hxx> - #ifdef DBG_UTIL #include <svdibrow.hxx> #endif @@ -69,6 +72,7 @@ #include <svx/svddrgv.hxx> // fuer SetSolidDragging() #include "svdstr.hrc" // Namen aus der Resource #include "svdglob.hxx" // StringCache +#include "globl3d.hxx" #include <svx/outliner.hxx> #include <svx/adjitem.hxx> @@ -1923,3 +1927,223 @@ void SdrObjEditView::OnEndPasteOrDrop( PasteOrDropInfos* ) // applications can derive from these virtual methods to do something before a drop or paste operation } +bool SdrObjEditView::SupportsFormatPaintbrush( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const +{ + if( nObjectInventor != SdrInventor && nObjectInventor != E3dInventor ) + return false; + switch(nObjectIdentifier) + { + case OBJ_NONE: + case OBJ_GRUP: + return false; + case OBJ_LINE: + case OBJ_RECT: + case OBJ_CIRC: + case OBJ_SECT: + case OBJ_CARC: + case OBJ_CCUT: + case OBJ_POLY: + case OBJ_PLIN: + case OBJ_PATHLINE: + case OBJ_PATHFILL: + case OBJ_FREELINE: + case OBJ_FREEFILL: + case OBJ_SPLNLINE: + case OBJ_SPLNFILL: + case OBJ_TEXT: + case OBJ_TEXTEXT: + case OBJ_TITLETEXT: + case OBJ_OUTLINETEXT: + case OBJ_GRAF: + case OBJ_OLE2: + case OBJ_TABLE: + return true; + case OBJ_EDGE: + case OBJ_CAPTION: + return false; + case OBJ_PATHPOLY: + case OBJ_PATHPLIN: + return true; + case OBJ_PAGE: + case OBJ_MEASURE: + case OBJ_DUMMY: + case OBJ_FRAME: + case OBJ_UNO: + return false; + case OBJ_CUSTOMSHAPE: + return true; + default: + return false; + } +} + +static const USHORT* GetFormatRangeImpl( bool bTextOnly ) +{ + static const USHORT gRanges[] = { + SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, + SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, + SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST, + XATTR_LINE_FIRST, XATTR_LINE_LAST, + XATTR_FILL_FIRST, XATTRSET_FILL, + EE_PARA_START, EE_PARA_END, + EE_CHAR_START, EE_CHAR_END, + 0,0 + }; + return &gRanges[ bTextOnly ? 10 : 0]; +} + +bool SdrObjEditView::TakeFormatPaintBrush( boost::shared_ptr< SfxItemSet >& rFormatSet ) +{ + if( mxSelectionController.is() && mxSelectionController->TakeFormatPaintBrush(rFormatSet) ) + return true; + + const SdrMarkList& rMarkList = GetMarkedObjectList(); + if( rMarkList.GetMarkCount() >= 1 ) + { + OutlinerView* pOLV = GetTextEditOutlinerView(); + + rFormatSet.reset( new SfxItemSet( GetModel()->GetItemPool(), GetFormatRangeImpl( pOLV != NULL ) ) ); + if( pOLV ) + { + rFormatSet->Put( pOLV->GetAttribs() ); + } + else + { + const BOOL bOnlyHardAttr = FALSE; + rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) ); + } + return true; + } + + return false; +} + +static SfxItemSet CreatePaintSet( const USHORT *pRanges, SfxItemPool& rPool, const SfxItemSet& rSourceSet, const SfxItemSet& rTargetSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) +{ + SfxItemSet aPaintSet( rPool, pRanges ); + + while( *pRanges ) + { + USHORT nWhich = *pRanges++; + const USHORT nLastWhich = *pRanges++; + + if( bNoCharacterFormats && (nWhich == EE_CHAR_START) ) + continue; + + if( bNoParagraphFormats && (nWhich == EE_PARA_START ) ) + continue; + + for( ; nWhich < nLastWhich; nWhich++ ) + { + const SfxPoolItem* pSourceItem = rSourceSet.GetItem( nWhich ); + const SfxPoolItem* pTargetItem = rTargetSet.GetItem( nWhich ); + + if( (pSourceItem && !pTargetItem) || (pSourceItem && pTargetItem && !((*pSourceItem) == (*pTargetItem)) ) ) + { + aPaintSet.Put( *pSourceItem ); + } + } + } + return aPaintSet; +} + +void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTextObj& rTextObj, SdrText* pText, bool bNoCharacterFormats, bool bNoParagraphFormats ) +{ + OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; + if(pParaObj) + { + SdrOutliner& rOutliner = rTextObj.ImpGetDrawOutliner(); + rOutliner.SetText(*pParaObj); + + sal_uInt32 nParaCount(rOutliner.GetParagraphCount()); + + if(nParaCount) + { + for(sal_uInt16 nPara = 0; nPara < nParaCount; nPara++) + { + if( !bNoCharacterFormats ) + rOutliner.QuickRemoveCharAttribs( nPara, /* remove all */0 ); + + SfxItemSet aSet(rOutliner.GetParaAttribs(nPara)); + aSet.Put(CreatePaintSet( GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) ); + rOutliner.SetParaAttribs(nPara, aSet); + } + + OutlinerParaObject* pTemp = rOutliner.CreateParaObject(0, (sal_uInt16)nParaCount); + rOutliner.Clear(); + + rTextObj.NbcSetOutlinerParaObjectForText(pTemp,pText); + } + } +} + +void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats ) +{ + if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) ) + { + const SdrMarkList& rMarkList = GetMarkedObjectList(); + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + OutlinerView* pOLV = GetTextEditOutlinerView(); + + const SfxItemSet& rShapeSet = pObj->GetMergedItemSet(); + + if( !pOLV ) + { + // if not in text edit mode (aka the user selected text or clicked on a word) + // apply formating attributes to selected shape + // All formating items (see ranges above) that are unequal in selected shape and + // the format paintbrush are hard set on the selected shape. + + const USHORT* pRanges = rFormatSet.GetRanges(); + bool bTextOnly = true; + + while( *pRanges ) + { + if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) ) + { + bTextOnly = false; + break; + } + pRanges += 2; + } + + if( !bTextOnly ) + { + SfxItemSet aPaintSet( CreatePaintSet( GetFormatRangeImpl(false), *rShapeSet.GetPool(), rFormatSet, rShapeSet, bNoCharacterFormats, bNoParagraphFormats ) ); + const BOOL bReplaceAll = FALSE; + SetAttrToMarked(aPaintSet, bReplaceAll); + } + + // now apply character and paragraph formating to text, if the shape has any + SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj); + if( pTextObj ) + { + sal_Int32 nText = pTextObj->getTextCount(); + + while( --nText >= 0 ) + { + SdrText* pText = pTextObj->getText( nText ); + ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats ); + } + } + } + else + { + ::Outliner* pOutliner = pOLV->GetOutliner(); + if( pOutliner ) + { + const EditEngine& rEditEngine = pOutliner->GetEditEngine(); + + ESelection aSel( pOLV->GetSelection() ); + if( !aSel.HasRange() ) + pOLV->SetSelection( rEditEngine.GetWord( aSel, com::sun::star::i18n::WordType::DICTIONARY_WORD ) ); + + const BOOL bRemoveParaAttribs = !bNoParagraphFormats; + pOLV->RemoveAttribsKeepLanguages( bRemoveParaAttribs ); + SfxItemSet aSet( pOLV->GetAttribs() ); + SfxItemSet aPaintSet( CreatePaintSet(GetFormatRangeImpl(true), *aSet.GetPool(), rFormatSet, aSet, bNoCharacterFormats, bNoParagraphFormats ) ); + pOLV->SetAttribs( aPaintSet ); + } + } + } +} diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index cba0d1aaf421..072c40c8a1f3 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -800,32 +800,47 @@ void SdrTextObj::impDecomposeBlockTextPrimitive( const bool bVerticalWritintg(rSdrBlockTextPrimitive.getOutlinerParaObject().IsVertical()); const Size aAnchorTextSize(Size(nAnchorTextWidth, nAnchorTextHeight)); - // check if block text is used (only one of them can be true) - const bool bHorizontalIsBlock(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg); - const bool bVerticalIsBlock(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg); - - // set minimal paper size hor/ver if needed - if(bHorizontalIsBlock) - { - rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0)); - } - else if(bVerticalIsBlock) - { - rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight)); - } - if(bIsCell) { // cell text is formated neither like a text object nor like a object // text, so use a special setup here rOutliner.SetMaxAutoPaperSize(aAnchorTextSize); + + // #i106214# To work with an unchangeable PaperSize (CellSize in + // this case) Set(Min|Max)AutoPaperSize and SetPaperSize have to be used. + // #i106214# This was not completely correct; to still measure the real + // text height to allow vertical adjust (and vice versa for VerticalWritintg) + // only one aspect has to be set, but the other one to zero + if(bVerticalWritintg) + { + // measure the horizontal text size + rOutliner.SetMinAutoPaperSize(Size(0, aAnchorTextSize.Height())); + } + else + { + // measure the vertical text size + rOutliner.SetMinAutoPaperSize(Size(aAnchorTextSize.Width(), 0)); + } + rOutliner.SetPaperSize(aAnchorTextSize); rOutliner.SetUpdateMode(true); rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject()); - rOutliner.SetControlWord(nOriginalControlWord); } else { + // check if block text is used (only one of them can be true) + const bool bHorizontalIsBlock(SDRTEXTHORZADJUST_BLOCK == eHAdj && !bVerticalWritintg); + const bool bVerticalIsBlock(SDRTEXTVERTADJUST_BLOCK == eVAdj && bVerticalWritintg); + + // set minimal paper size hor/ver if needed + if(bHorizontalIsBlock) + { + rOutliner.SetMinAutoPaperSize(Size(nAnchorTextWidth, 0)); + } + else if(bVerticalIsBlock) + { + rOutliner.SetMinAutoPaperSize(Size(0, nAnchorTextHeight)); + } if((rSdrBlockTextPrimitive.getWordWrap() || IsTextFrame()) && !rSdrBlockTextPrimitive.getUnlimitedPage()) { @@ -854,9 +869,10 @@ void SdrTextObj::impDecomposeBlockTextPrimitive( rOutliner.SetPaperSize(aNullSize); rOutliner.SetUpdateMode(true); rOutliner.SetText(rSdrBlockTextPrimitive.getOutlinerParaObject()); - rOutliner.SetControlWord(nOriginalControlWord); } + rOutliner.SetControlWord(nOriginalControlWord); + // now get back the layouted text size from outliner const Size aOutlinerTextSiz(rOutliner.GetPaperSize()); const basegfx::B2DVector aOutlinerScale(aOutlinerTextSiz.Width(), aOutlinerTextSiz.Height()); diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 05b5b5e5aca6..55e0347e6522 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -671,7 +671,13 @@ const Rectangle& SdrObjList::GetAllObjSnapRect() const const Rectangle& SdrObjList::GetAllObjBoundRect() const { - if (bRectsDirty) { + // #i106183# for deep group hierarchies like in chart2, the invalidates + // through the hierarchy are not correct; use a 2nd hint for the needed + // recalculation. Future versions will have no bool flag at all, but + // just aOutRect in empty state to representate an invalid state, thus + // it's a step in the right direction. + if (bRectsDirty || aOutRect.IsEmpty()) + { ((SdrObjList*)this)->RecalcRects(); ((SdrObjList*)this)->bRectsDirty=FALSE; } |