summaryrefslogtreecommitdiff
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-12 20:38:24 +0000
commit2670760550608c3f51bb01eb7b86c33461e2e5c8 (patch)
tree8a6d86981370bd7c0726f73574e32cdba9089cb8
parent104a31ea86ed3270ee5392bb09a66b4e063acb69 (diff)
tdf#104405 Clone Formatting ignores vertical text alignment
I removed the unit test, since it depends on some other changes to the dumpAsXml code that are not in this branch. 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) Reviewed-on: https://gerrit.libreoffice.org/31746 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com> (cherry picked from commit a7d13674bc2271e6f191e8ecda78151a47d413f6) Change-Id: I56cce69ddb21f7f9336b8f59e181e91306e92019 Reviewed-on: https://gerrit.libreoffice.org/31896 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--include/svx/sdtaitm.hxx1
-rw-r--r--include/svx/svdotable.hxx1
-rw-r--r--svx/source/svdraw/svdattr.cxx8
-rw-r--r--svx/source/svdraw/svdedxv.cxx131
-rw-r--r--svx/source/table/svdotable.cxx4
5 files changed, 94 insertions, 51 deletions
diff --git a/include/svx/sdtaitm.hxx b/include/svx/sdtaitm.hxx
index 590df23ce2ce..fc20689c1e8e 100644
--- a/include/svx/sdtaitm.hxx
+++ b/include/svx/sdtaitm.hxx
@@ -48,6 +48,7 @@ public:
virtual OUString GetValueTextByPos(sal_uInt16 nPos) const override;
virtual bool GetPresentation(SfxItemPresentation ePres, SfxMapUnit eCoreMetric, SfxMapUnit ePresMetric, OUString& rText, const IntlWrapper * = nullptr) const override;
+ virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
};
diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx
index b0e0c5c16d4c..ac29effd8a0e 100644
--- a/include/svx/svdotable.hxx
+++ b/include/svx/svdotable.hxx
@@ -141,6 +141,7 @@ public:
void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
const SfxItemSet& GetActiveCellItemSet() const;
+ void SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems);
void setTableStyle( const css::uno::Reference< css::container::XIndexAccess >& xAutoFormatStyle );
const css::uno::Reference< css::container::XIndexAccess >& getTableStyle() const;
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 5a0570c93832..3e98047a4c3c 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;
@@ -1129,6 +1130,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 711ae9348977..968738c6fde0 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2098,8 +2098,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];
@@ -2125,6 +2126,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 ) && (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);
+ }
+ }
}
}
@@ -2189,71 +2201,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();
-
- ESelection aSel( pOLV->GetSelection() );
- if( !aSel.HasRange() )
- pOLV->SetSelection( rEditEngine.GetWord( aSel, css::i18n::WordType::DICTIONARY_WORD ) );
+ const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+
+ 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) && (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 f82890732c08..34b78caa6b84 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1179,6 +1179,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 )
{