1th part of bnc#870233: wrong list style in shapes

Text list styles were copied, without proper
copy constructor and operator. It lad to mix
up list styles and so text font.

Change-Id: Iee7a6c0c1f74322fd7b80e41a262849f948e463a
This commit is contained in:
Zolnai Tamás
2014-06-05 18:43:04 +02:00
parent 80ef7a645a
commit 31650d5b42
4 changed files with 104 additions and 0 deletions

View File

@@ -34,6 +34,9 @@ public:
TextListStyle();
~TextListStyle();
TextListStyle(const TextListStyle& rStyle);
TextListStyle& operator=(const TextListStyle& rStyle);
void apply( const TextListStyle& rTextListStyle );
const TextParagraphPropertiesVector& getListStyle() const { return maListStyle; };

View File

@@ -34,6 +34,34 @@ TextListStyle::~TextListStyle()
{
}
TextListStyle::TextListStyle(const TextListStyle& rStyle)
{
assert(rStyle.maListStyle.size() == 9);
assert(rStyle.maAggregationListStyle.size() == 9);
for ( size_t i = 0; i < 9; i++ )
{
maListStyle.push_back( TextParagraphPropertiesPtr( new TextParagraphProperties(*rStyle.maListStyle[i]) ) );
maAggregationListStyle.push_back( TextParagraphPropertiesPtr( new TextParagraphProperties(*rStyle.maAggregationListStyle[i]) ) );
}
}
TextListStyle& TextListStyle::operator=(const TextListStyle& rStyle)
{
if(this != &rStyle)
{
assert(rStyle.maListStyle.size() == 9);
assert(rStyle.maAggregationListStyle.size() == 9);
assert(maListStyle.size() == 9);
assert(maAggregationListStyle.size() == 9);
for ( size_t i = 0; i < 9; i++ )
{
*maListStyle[i] = *rStyle.maListStyle[i];
*maAggregationListStyle[i] = *rStyle.maAggregationListStyle[i];
}
}
return *this;
}
void applyStyleList( const TextParagraphPropertiesVector& rSourceListStyle, TextParagraphPropertiesVector& rDestListStyle )
{
TextParagraphPropertiesVector::const_iterator aSourceListStyleIter( rSourceListStyle.begin() );

Binary file not shown.

View File

@@ -20,6 +20,7 @@
#include <editeng/wghtitem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/postitem.hxx>
#include <rsc/rscsfx.hxx>
#include <svx/svdotext.hxx>
@@ -74,6 +75,7 @@ public:
void testFdo71961();
void testMediaEmbedding();
void testBnc870237();
void testBnc870233_1();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
@@ -99,6 +101,7 @@ public:
CPPUNIT_TEST(testFdo71961);
CPPUNIT_TEST(testMediaEmbedding);
CPPUNIT_TEST(testBnc870237);
CPPUNIT_TEST(testBnc870233_1);
CPPUNIT_TEST_SUITE_END();
};
@@ -760,6 +763,76 @@ void SdFiltersTest::testBnc870237()
xDocShRef->DoClose();
}
void SdFiltersTest::testBnc870233_1()
{
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"));
xDocShRef = saveAndReload( xDocShRef, PPTX );
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
const SdrPage *pPage = pDoc->GetPage (1);
CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
// The problem was all shapes had the same font (the last parsed font attribues overwrote all previous ones)
// First shape has red, bold font
{
const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) );
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject();
std::vector<EECharAttrib> rLst;
aEdit.GetCharAttribs(0, rLst);
for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
{
const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr);
if( pCharColor )
{
CPPUNIT_ASSERT_EQUAL( sal_uInt32(0xff0000), pCharColor->GetValue().GetColor());
}
const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
if( pWeight )
{
CPPUNIT_ASSERT_EQUAL( FontWeight::WEIGHT_BOLD, pWeight->GetWeight());
}
const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr);
if( pPosture )
{
CPPUNIT_ASSERT_EQUAL( FontItalic::ITALIC_NONE, pPosture->GetPosture());
}
}
}
// Second shape has blue, italic font
{
const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) );
CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject();
std::vector<EECharAttrib> rLst;
aEdit.GetCharAttribs(0, rLst);
for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
{
const SvxColorItem *pCharColor = dynamic_cast<const SvxColorItem *>((*it).pAttr);
if( pCharColor )
{
CPPUNIT_ASSERT_EQUAL( sal_uInt32(0x0000ff), pCharColor->GetValue().GetColor());
}
const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
if( pWeight )
{
CPPUNIT_ASSERT_EQUAL( FontWeight::WEIGHT_NORMAL, pWeight->GetWeight());
}
const SvxPostureItem *pPosture = dynamic_cast<const SvxPostureItem *>((*it).pAttr);
if( pPosture )
{
CPPUNIT_ASSERT_EQUAL( FontItalic::ITALIC_NORMAL, pPosture->GetPosture());
}
}
}
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();