tdf#104405 Clone Formatting ignores vertical text alignment
Change-Id: I56cce69ddb21f7f9336b8f59e181e91306e92019 Reviewed-on: https://gerrit.libreoffice.org/31623 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
committed by
Miklos Vajna
parent
00afb44987
commit
d36aa2ba31
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
virtual OUString GetValueTextByPos(sal_uInt16 nPos) const override;
|
virtual OUString GetValueTextByPos(sal_uInt16 nPos) const override;
|
||||||
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper * = nullptr) const override;
|
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString& rText, const IntlWrapper * = nullptr) const override;
|
||||||
|
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -141,6 +141,7 @@ public:
|
|||||||
void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
|
void getCellBounds( const sdr::table::CellPos& rPos, ::Rectangle& rCellRect );
|
||||||
|
|
||||||
const SfxItemSet& GetActiveCellItemSet() const;
|
const SfxItemSet& GetActiveCellItemSet() const;
|
||||||
|
void SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems);
|
||||||
|
|
||||||
void setTableStyle( const css::uno::Reference< css::container::XIndexAccess >& xAutoFormatStyle );
|
void setTableStyle( const css::uno::Reference< css::container::XIndexAccess >& xAutoFormatStyle );
|
||||||
const css::uno::Reference< css::container::XIndexAccess >& getTableStyle() const;
|
const css::uno::Reference< css::container::XIndexAccess >& getTableStyle() const;
|
||||||
|
1103
sd/qa/unit/tiledrendering/data/tdf104405.fodp
Normal file
1103
sd/qa/unit/tiledrendering/data/tdf104405.fodp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -80,6 +80,7 @@ public:
|
|||||||
void testTdf102223();
|
void testTdf102223();
|
||||||
void testPostKeyEventInvalidation();
|
void testPostKeyEventInvalidation();
|
||||||
void testTdf103083();
|
void testTdf103083();
|
||||||
|
void testTdf104405();
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
|
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
|
||||||
CPPUNIT_TEST(testRegisterCallback);
|
CPPUNIT_TEST(testRegisterCallback);
|
||||||
@@ -110,6 +111,7 @@ public:
|
|||||||
CPPUNIT_TEST(testTdf102223);
|
CPPUNIT_TEST(testTdf102223);
|
||||||
CPPUNIT_TEST(testPostKeyEventInvalidation);
|
CPPUNIT_TEST(testPostKeyEventInvalidation);
|
||||||
CPPUNIT_TEST(testTdf103083);
|
CPPUNIT_TEST(testTdf103083);
|
||||||
|
CPPUNIT_TEST(testTdf104405);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1407,6 +1409,63 @@ void SdTiledRenderingTest::testTdf103083()
|
|||||||
comphelper::LibreOfficeKit::setActive(false);
|
comphelper::LibreOfficeKit::setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tests a clone-formatting bug around table cell attributes
|
||||||
|
*/
|
||||||
|
void SdTiledRenderingTest::testTdf104405()
|
||||||
|
{
|
||||||
|
// Load the document.
|
||||||
|
comphelper::LibreOfficeKit::setActive();
|
||||||
|
SdXImpressDocument* pXImpressDocument = createDoc("tdf104405.fodp");
|
||||||
|
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
|
||||||
|
SdPage* pActualPage = pViewShell->GetActualPage();
|
||||||
|
SdrObject* pObject = pActualPage->GetObj(2);
|
||||||
|
auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pObject);
|
||||||
|
CPPUNIT_ASSERT(pTableObject);
|
||||||
|
|
||||||
|
// select the middle cell
|
||||||
|
SdrView* pView = pViewShell->GetView();
|
||||||
|
pView->MarkObj(pTableObject, pView->GetSdrPageView());
|
||||||
|
pTableObject->setActiveCell(sdr::table::CellPos(2,1));
|
||||||
|
pView->SdrBeginTextEdit(pTableObject);
|
||||||
|
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
|
||||||
|
rEditView.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char.
|
||||||
|
|
||||||
|
// trigger the clone-formatting/paintbrush command to copy formatting contents of cell
|
||||||
|
uno::Sequence< beans::PropertyValue > aArgs( 1 );
|
||||||
|
aArgs[0].Name = "PersistentCopy";
|
||||||
|
aArgs[0].Value = uno::makeAny( true );
|
||||||
|
comphelper::dispatchCommand(".uno:FormatPaintbrush", aArgs);
|
||||||
|
|
||||||
|
Scheduler::ProcessEventsToIdle();
|
||||||
|
|
||||||
|
// now click on the table
|
||||||
|
pView->MarkObj(pTableObject, pView->GetSdrPageView());
|
||||||
|
pTableObject->setActiveCell(sdr::table::CellPos(0,0));
|
||||||
|
pView->SdrBeginTextEdit(pTableObject);
|
||||||
|
EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
|
||||||
|
rEditView2.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char.
|
||||||
|
Rectangle aRect = pTableObject->GetCurrentBoundRect();
|
||||||
|
pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
|
||||||
|
convertMm100ToTwip(aRect.getX() ), convertMm100ToTwip(aRect.getY() ),
|
||||||
|
1, MOUSE_LEFT, 0);
|
||||||
|
pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
|
||||||
|
convertMm100ToTwip(aRect.getX() ), convertMm100ToTwip(aRect.getY() ),
|
||||||
|
1, MOUSE_LEFT, 0);
|
||||||
|
|
||||||
|
Scheduler::ProcessEventsToIdle();
|
||||||
|
|
||||||
|
// check that the first cell has acquired the resulting vertical style
|
||||||
|
xmlDocPtr pXmlDoc = parseXmlDump();
|
||||||
|
OString aPrefix = "/SdDrawDocument/SdrModel/SdPage/SdrObjList/SdrTableObj/SdrTableObjImpl"
|
||||||
|
"/TableModel/Cell[1]/DefaultProperties/SfxItemSet/SdrTextVertAdjustItem";
|
||||||
|
// the following name has a compiler-dependant part
|
||||||
|
CPPUNIT_ASSERT_EQUAL( getXPath(pXmlDoc, aPrefix, "value"), OUString("2") );
|
||||||
|
xmlFreeDoc(pXmlDoc);
|
||||||
|
|
||||||
|
comphelper::LibreOfficeKit::setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
|
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
|
||||||
|
|
||||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||||
|
@@ -100,6 +100,7 @@
|
|||||||
#include <svx/xflclit.hxx>
|
#include <svx/xflclit.hxx>
|
||||||
#include <svx/xlineit0.hxx>
|
#include <svx/xlineit0.hxx>
|
||||||
#include <svx/xtable.hxx>
|
#include <svx/xtable.hxx>
|
||||||
|
#include <libxml/xmlwriter.h>
|
||||||
|
|
||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
@@ -1110,6 +1111,13 @@ bool SdrTextVertAdjustItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberI
|
|||||||
return true;
|
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); }
|
SfxPoolItem* SdrTextHorzAdjustItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextHorzAdjustItem(*this); }
|
||||||
|
|
||||||
|
@@ -2202,8 +2202,9 @@ static const sal_uInt16* GetFormatRangeImpl( bool bTextOnly )
|
|||||||
SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
|
SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
|
||||||
XATTR_LINE_FIRST, XATTR_LINE_LAST,
|
XATTR_LINE_FIRST, XATTR_LINE_LAST,
|
||||||
XATTR_FILL_FIRST, XATTRSET_FILL,
|
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,
|
EE_CHAR_START, EE_CHAR_END,
|
||||||
|
SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, // table cell formats
|
||||||
0,0
|
0,0
|
||||||
};
|
};
|
||||||
return &gRanges[ bTextOnly ? 10 : 0];
|
return &gRanges[ bTextOnly ? 10 : 0];
|
||||||
@@ -2229,6 +2230,17 @@ void SdrObjEditView::TakeFormatPaintBrush( std::shared_ptr< SfxItemSet >& rForma
|
|||||||
const bool bOnlyHardAttr = false;
|
const bool bOnlyHardAttr = false;
|
||||||
rFormatSet->Put( GetAttrFromMarked(bOnlyHardAttr) );
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2300,9 +2312,9 @@ void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoChar
|
|||||||
}
|
}
|
||||||
|
|
||||||
OutlinerView* pOLV = GetTextEditOutlinerView();
|
OutlinerView* pOLV = GetTextEditOutlinerView();
|
||||||
|
const SdrMarkList& rMarkList = GetMarkedObjectList();
|
||||||
if( !pOLV )
|
if( !pOLV )
|
||||||
{
|
{
|
||||||
const SdrMarkList& rMarkList = GetMarkedObjectList();
|
|
||||||
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
|
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
|
||||||
const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
|
const SfxItemSet& rShapeSet = pObj->GetMergedItemSet();
|
||||||
|
|
||||||
@@ -2367,6 +2379,17 @@ void SdrObjEditView::ApplyFormatPaintBrush( SfxItemSet& rFormatSet, bool bNoChar
|
|||||||
pOLV->SetAttribs( aPaintSet );
|
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*/);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -1171,6 +1171,10 @@ const SfxItemSet& SdrTableObj::GetActiveCellItemSet() const
|
|||||||
return getActiveCell()->GetItemSet();
|
return getActiveCell()->GetItemSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SdrTableObj::SetMergedItemSetAndBroadcastOnActiveCell(const SfxItemSet& rSet, bool bClearAllItems)
|
||||||
|
{
|
||||||
|
return getActiveCell()->SetMergedItemSetAndBroadcast(rSet, bClearAllItems);
|
||||||
|
}
|
||||||
|
|
||||||
void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
|
void SdrTableObj::setTableStyle( const Reference< XIndexAccess >& xTableStyle )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user