summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2016-12-05 11:51:01 +0200
committerAndras Timar <andras.timar@collabora.com>2016-12-08 10:36:43 +0000
commita7d13674bc2271e6f191e8ecda78151a47d413f6 (patch)
tree4a0536079ae887cf8178bc65098f036c89d63bba /svx
parenta1f6159db30e2463b118c1571bb01a09356b7c49 (diff)
tdf#104405 Clone Formatting ignores vertical text alignment
Reviewed-on: https://gerrit.libreoffice.org/31623 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit d36aa2ba3132ce62a370b7260ca620642cbf7dbf) Change-Id: I56cce69ddb21f7f9336b8f59e181e91306e92019 Reviewed-on: https://gerrit.libreoffice.org/31746 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svdattr.cxx8
-rw-r--r--svx/source/svdraw/svdedxv.cxx129
-rw-r--r--svx/source/table/svdotable.cxx4
3 files changed, 91 insertions, 50 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 1100b0e3156d..196a344b6111 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -100,6 +100,7 @@
#include <svx/xflclit.hxx>
#include <svx/xlineit0.hxx>
#include <svx/xtable.hxx>
+#include <libxml/xmlwriter.h>
using namespace ::com::sun::star;
@@ -1110,6 +1111,13 @@ bool SdrTextVertAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberI
return true;
}
+void SdrTextVertAdjustItem::dumpAsXml(struct _xmlTextWriter* pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("SdrTextVertAdjustItem"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::number(GetValue()).getStr()));
+ xmlTextWriterEndElement(pWriter);
+}
SfxPoolItem* SdrTextHorzAdjustItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextHorzAdjustItem(*this); }
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 2f618b0e10fa..b413f51e34e0 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2202,8 +2202,9 @@ static const sal_uInt16* GetFormatRangeImpl( bool bTextOnly )
SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
XATTR_LINE_FIRST, XATTR_LINE_LAST,
XATTR_FILL_FIRST, XATTRSET_FILL,
- EE_PARA_START, EE_PARA_END,
+ EE_PARA_START, EE_PARA_END, // text-only from here on
EE_CHAR_START, EE_CHAR_END,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, // table cell formats
0,0
};
return &gRanges[ bTextOnly ? 10 : 0];
@@ -2229,6 +2230,17 @@ void SdrObjEditView::TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rForma
const bool bOnlyHardAttr = false;
rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) );
}
+
+ // check for cloning from table cell, in which case we need to copy cell-specific formatting attributes
+ const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj && (pObj->GetObjInventor() == SdrInventor::Default ) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+ {
+ auto pTable = static_cast<const sdr::table::SdrTableObj*>(pObj);
+ if (pTable->getActiveCell().is()) {
+ SfxItemSet const & rSet = pTable->GetActiveCellItemSet();
+ rFormatSet->Put(rSet);
+ }
+ }
}
}
@@ -2293,71 +2305,88 @@ void SdrObjEditView::ApplyFormatPaintBrushToText( SfxItemSet& rFormatSet, SdrTex
void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoCharacterFormats, bool bNoParagraphFormats )
{
- if( !mxSelectionController.is() || !mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
+ if( mxSelectionController.is() &&
+ mxSelectionController->ApplyFormatPaintBrush( rFormatSet, bNoCharacterFormats, bNoParagraphFormats ) )
{
- const SdrMarkList& rMarkList = GetMarkedObjectList();
- SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- OutlinerView* pOLV = GetTextEditOutlinerView();
+ return;
+ }
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ if( !pOLV )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
- if( !pOLV )
- {
- // if not in text edit mode (aka the user selected text or clicked on a word)
- // apply formatting attributes to selected shape
- // All formatting items (see ranges above) that are unequal in selected shape and
- // the format paintbrush are hard set on the selected shape.
+ // if not in text edit mode (aka the user selected text or clicked on a word)
+ // apply formatting attributes to selected shape
+ // All formatting items (see ranges above) that are unequal in selected shape and
+ // the format paintbrush are hard set on the selected shape.
- const sal_uInt16* pRanges = rFormatSet.GetRanges();
- bool bTextOnly = true;
+ const sal_uInt16* pRanges = rFormatSet.GetRanges();
+ bool bTextOnly = true;
- while( *pRanges )
+ while( *pRanges )
+ {
+ if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
{
- if( (*pRanges != EE_PARA_START) && (*pRanges != EE_CHAR_START) )
- {
- bTextOnly = false;
- break;
- }
- pRanges += 2;
+ 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);
- }
+ if( !bTextOnly )
+ {
+ SfxItemSet aPaintSet( CreatePaintSet(
+ GetFormatRangeImpl(false), *rShapeSet.GetPool(),
+ rFormatSet, rShapeSet,
+ bNoCharacterFormats, bNoParagraphFormats ) );
+ SetAttrToMarked(aPaintSet, false/*bReplaceAll*/);
+ }
- // now apply character and paragraph formatting to text, if the shape has any
- SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObj);
- if( pTextObj )
- {
- sal_Int32 nText = pTextObj->getTextCount();
+ // now apply character and paragraph formatting 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 );
- }
+ while( --nText >= 0 )
+ {
+ SdrText* pText = pTextObj->getText( nText );
+ ApplyFormatPaintBrushToText( rFormatSet, *pTextObj, pText, bNoCharacterFormats, bNoParagraphFormats );
}
}
- else
+ }
+ else
+ {
+ ::Outliner* pOutliner = pOLV->GetOutliner();
+ if( pOutliner )
{
- ::Outliner* pOutliner = pOLV->GetOutliner();
- if( pOutliner )
- {
- const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+ const EditEngine& rEditEngine = pOutliner->GetEditEngine();
- ESelection aSel( pOLV->GetSelection() );
- if( !aSel.HasRange() )
- pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
+ ESelection aSel( pOLV->GetSelection() );
+ if( !aSel.HasRange() )
+ pOLV->SetSelection( rEditEngine.GetWord( aSel, css::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 );
- }
+ 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 );
+ }
+ }
+
+ // check for cloning to table cell, in which case we need to copy cell-specific formatting attributes
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj && (pObj->GetObjInventor() == SdrInventor::Default) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+ {
+ auto pTable = static_cast<sdr::table::SdrTableObj*>(pObj);
+ if (pTable->getActiveCell().is()) {
+ pTable->SetMergedItemSetAndBroadcastOnActiveCell(rFormatSet, false/*bClearAllItems*/);
}
}
}
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 2c8a9907c967..d53ddfffd777 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1178,6 +1178,10 @@ const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const
return getActiveCell()->GetItemSet();
}
+void SdrTableObj::SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems)
+{
+ return getActiveCell()->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
+}
void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
{