[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sd/qa sd/source
Tamás Zolnai
tamas.zolnai at collabora.com
Fri Aug 25 14:00:46 UTC 2017
sd/qa/unit/data/pptx/tdf108926.ppt |binary
sd/qa/unit/import-tests.cxx | 19 ++
sd/source/filter/ppt/pptin.cxx | 321 ++++++++++++++++++-------------------
3 files changed, 178 insertions(+), 162 deletions(-)
New commits:
commit b9763e77863cd4db843a72c3a3d75555291ed8ae
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Thu Aug 24 14:29:00 2017 +0200
tdf#108926: Notes placeholder text boxes not shown in PPTs
Regression from:
acb2943c8125f4ceed74f35f31776929dedeb8d8
Call this placeholder related code not only for
normal slide pages.
Reviewed-on: https://gerrit.libreoffice.org/41517
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit b766cab621690a3aaf4e10fcf925ebab1c1925b8)
Change-Id: Iae185ac7e5d2505554692045516cc51dbdcd735b
Reviewed-on: https://gerrit.libreoffice.org/41528
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/sd/qa/unit/data/pptx/tdf108926.ppt b/sd/qa/unit/data/pptx/tdf108926.ppt
new file mode 100644
index 000000000000..c8455e226e1b
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf108926.ppt differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index c657ebc352c1..ab58fe2fd7c0 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -149,6 +149,7 @@ public:
void testTdf108925();
void testTdf109223();
void testActiveXCheckbox();
+ void testTdf108926();
bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
void testPatternImport();
@@ -217,6 +218,7 @@ public:
CPPUNIT_TEST(testTdf108925);
CPPUNIT_TEST(testTdf109223);
CPPUNIT_TEST(testActiveXCheckbox);
+ CPPUNIT_TEST(testTdf108926);
CPPUNIT_TEST_SUITE_END();
};
@@ -2240,6 +2242,23 @@ void SdImportTest::testActiveXCheckbox()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf108926()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf108926.ppt"), PPT);
+ uno::Reference< presentation::XPresentationPage > xPage (getPage(0, xDocShRef), uno::UNO_QUERY_THROW);
+ uno::Reference< drawing::XDrawPage > xNotesPage (xPage->getNotesPage(), uno::UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xNotesPage->getCount());
+
+ // Second object should be imported as an empty presentation shape
+ uno::Reference< beans::XPropertySet > xPresentationShape(xNotesPage->getByIndex(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xPresentationShape.is());
+ bool bIsEmptyPresObject = false;
+ xPresentationShape->getPropertyValue( "IsEmptyPresentationObject" ) >>= bIsEmptyPresObject;
+ CPPUNIT_ASSERT(bIsEmptyPresObject);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index f2e90fc41cb6..755ea064ac68 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -2353,212 +2353,209 @@ SdrObject* ImplSdPPTImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj* pObj
sal_uInt32 nPlacementId = pPlaceHolder->nPlacementId;
PptPlaceholder nPlaceholderId = pPlaceHolder->nPlaceholderId;
- if ( eAktPageKind == PPT_SLIDEPAGE )
+ PresObjKind ePresObjKind = PRESOBJ_NONE;
+ bool bEmptyPresObj = true;
+ bool bVertical = false;
+ if ( ( pTextObj->GetShapeType() == mso_sptRectangle ) || ( pTextObj->GetShapeType() == mso_sptTextBox ) )
{
- PresObjKind ePresObjKind = PRESOBJ_NONE;
- bool bEmptyPresObj = true;
- bool bVertical = false;
- if ( ( pTextObj->GetShapeType() == mso_sptRectangle ) || ( pTextObj->GetShapeType() == mso_sptTextBox ) )
+ //if a placeholder with some custom attribute,the pTextObj will keep those attr,whose text size is zero,
+ //so sdPage should renew a PresObj to process placeholder.
+ bEmptyPresObj = ( pTextObj->Count() == 0 ) || ( pTextObj->Count() == 1 && pTextObj->First()->GetTextSize() == 0 );
+ switch ( nPlaceholderId )
{
- //if a placeholder with some custom attribute,the pTextObj will keep those attr,whose text size is zero,
- //so sdPage should renew a PresObj to process placeholder.
- bEmptyPresObj = ( pTextObj->Count() == 0 ) || ( pTextObj->Count() == 1 && pTextObj->First()->GetTextSize() == 0 );
- switch ( nPlaceholderId )
+ case PptPlaceholder::NOTESBODY : ePresObjKind = PRESOBJ_NOTES; break;
+ case PptPlaceholder::VERTICALTEXTTITLE :
+ bVertical = true;
+ SAL_FALLTHROUGH;
+ case PptPlaceholder::TITLE : ePresObjKind = PRESOBJ_TITLE; break;
+ case PptPlaceholder::VERTICALTEXTBODY :
+ bVertical = true;
+ SAL_FALLTHROUGH;
+ case PptPlaceholder::BODY : ePresObjKind = PRESOBJ_OUTLINE; break;
+ case PptPlaceholder::CENTEREDTITLE : ePresObjKind = PRESOBJ_TITLE; break;
+ case PptPlaceholder::SUBTITLE : ePresObjKind = PRESOBJ_TEXT; break; // PRESOBJ_OUTLINE
+
+ default :
{
- case PptPlaceholder::NOTESBODY : ePresObjKind = PRESOBJ_NOTES; break;
- case PptPlaceholder::VERTICALTEXTTITLE :
- bVertical = true;
- SAL_FALLTHROUGH;
- case PptPlaceholder::TITLE : ePresObjKind = PRESOBJ_TITLE; break;
- case PptPlaceholder::VERTICALTEXTBODY :
- bVertical = true;
- SAL_FALLTHROUGH;
- case PptPlaceholder::BODY : ePresObjKind = PRESOBJ_OUTLINE; break;
- case PptPlaceholder::CENTEREDTITLE : ePresObjKind = PRESOBJ_TITLE; break;
- case PptPlaceholder::SUBTITLE : ePresObjKind = PRESOBJ_TEXT; break; // PRESOBJ_OUTLINE
-
- default :
+ if ( pTextObj->Count() == 0 )
{
- if ( pTextObj->Count() == 0 )
+ switch ( nPlaceholderId )
{
- switch ( nPlaceholderId )
- {
- case PptPlaceholder::MEDIACLIP :
- case PptPlaceholder::OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
- case PptPlaceholder::GRAPH : ePresObjKind = PRESOBJ_CHART; break;
- case PptPlaceholder::TABLE : ePresObjKind = PRESOBJ_TABLE; break;
- case PptPlaceholder::CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
- case PptPlaceholder::ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
- default: break;
- }
+ case PptPlaceholder::MEDIACLIP :
+ case PptPlaceholder::OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
+ case PptPlaceholder::GRAPH : ePresObjKind = PRESOBJ_CHART; break;
+ case PptPlaceholder::TABLE : ePresObjKind = PRESOBJ_TABLE; break;
+ case PptPlaceholder::CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
+ case PptPlaceholder::ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
+ default: break;
}
- };
- }
+ }
+ };
}
- else if ( pTextObj->GetShapeType() == mso_sptPictureFrame )
+ }
+ else if ( pTextObj->GetShapeType() == mso_sptPictureFrame )
+ {
+ if ( !pTextObj->Count() && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr )
{
- if ( !pTextObj->Count() && dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr )
+ bEmptyPresObj = false;
+ switch ( nPlaceholderId )
{
- bEmptyPresObj = false;
- switch ( nPlaceholderId )
- {
- case PptPlaceholder::MEDIACLIP :
- case PptPlaceholder::OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
- case PptPlaceholder::GRAPH : ePresObjKind = PRESOBJ_CHART; break;
- case PptPlaceholder::TABLE : ePresObjKind = PRESOBJ_CALC; break;
- case PptPlaceholder::CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
- case PptPlaceholder::ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
- default: break;
- }
+ case PptPlaceholder::MEDIACLIP :
+ case PptPlaceholder::OBJECT : ePresObjKind = PRESOBJ_OBJECT; break;
+ case PptPlaceholder::GRAPH : ePresObjKind = PRESOBJ_CHART; break;
+ case PptPlaceholder::TABLE : ePresObjKind = PRESOBJ_CALC; break;
+ case PptPlaceholder::CLIPART : ePresObjKind = PRESOBJ_GRAPHIC; break;
+ case PptPlaceholder::ORGANISZATIONCHART : ePresObjKind = PRESOBJ_ORGCHART; break;
+ default: break;
}
}
- if ( ePresObjKind != PRESOBJ_NONE )
+ }
+ if ( ePresObjKind != PRESOBJ_NONE )
+ {
+ if ( !bEmptyPresObj )
+ {
+ pPage->InsertPresObj( pRet, ePresObjKind );
+ }
+ else
{
- if ( !bEmptyPresObj )
+ SdrObject* pPresObj = pPage->CreatePresObj( ePresObjKind, bVertical, pText->GetLogicRect(), true );
+ pPresObj->SetUserCall( pPage );
+
+ SfxItemSet aSet( pSdrModel->GetItemPool() );
+ ApplyAttributes( rStCtrl, aSet );
+ pPresObj->SetLogicRect(pText->GetLogicRect());
+ ApplyTextAnchorAttributes( *pTextObj, aSet );
+ //set custom font attribute of the placeholder
+ if ( pTextObj->Count() == 1 )
{
- pPage->InsertPresObj( pRet, ePresObjKind );
+ PPTParagraphObj* pPara = pTextObj->First();
+ PPTPortionObj* pPor = nullptr;
+ if ( pPara && pPara->GetTextSize() == 0 && (pPor = pPara->First()))
+ {
+ pPor->ApplyTo(aSet, (SdrPowerPointImport&)*this, pTextObj->GetDestinationInstance());
+ }
}
- else
+ pPresObj->SetMergedItemSet(aSet);
+
+ if ((eAktPageKind != PPT_NOTEPAGE) && (nPlacementId != 0xffffffff) && pPage->TRG_HasMasterPage())
{
- SdrObject* pPresObj = pPage->CreatePresObj( ePresObjKind, bVertical, pText->GetLogicRect(), true );
- pPresObj->SetUserCall( pPage );
-
- SfxItemSet aSet( pSdrModel->GetItemPool() );
- ApplyAttributes( rStCtrl, aSet );
- pPresObj->SetLogicRect(pText->GetLogicRect());
- ApplyTextAnchorAttributes( *pTextObj, aSet );
- //set custom font attribute of the placeholder
- if ( pTextObj->Count() == 1 )
+ SdrObject* pTitleObj = static_cast<SdPage&>(pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_TITLE );
+ SdrObject* pOutlineObj = static_cast<SdPage&>(pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_OUTLINE );
+
+ Rectangle aTitleRect;
+ Rectangle aOutlineRect;
+ Size aOutlineSize;
+
+ if ( pTitleObj )
+ aTitleRect = pTitleObj->GetLogicRect();
+ if ( pOutlineObj )
{
- PPTParagraphObj* pPara = pTextObj->First();
- PPTPortionObj* pPor = nullptr;
- if ( pPara && pPara->GetTextSize() == 0 && (pPor = pPara->First()))
- {
- pPor->ApplyTo(aSet, (SdrPowerPointImport&)*this, pTextObj->GetDestinationInstance());
- }
+ aOutlineRect = pOutlineObj->GetLogicRect();
+ aOutlineSize = aOutlineRect.GetSize();
}
- pPresObj->SetMergedItemSet(aSet);
+ Rectangle aLogicRect( pPresObj->GetLogicRect() );
+ Size aLogicSize( aLogicRect.GetSize() );
- if ((eAktPageKind != PPT_NOTEPAGE) && (nPlacementId != 0xffffffff) && pPage->TRG_HasMasterPage())
+ switch ( nPlacementId )
{
- SdrObject* pTitleObj = static_cast<SdPage&>(pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_TITLE );
- SdrObject* pOutlineObj = static_cast<SdPage&>(pPage->TRG_GetMasterPage()).GetPresObj( PRESOBJ_OUTLINE );
-
- Rectangle aTitleRect;
- Rectangle aOutlineRect;
- Size aOutlineSize;
-
- if ( pTitleObj )
- aTitleRect = pTitleObj->GetLogicRect();
- if ( pOutlineObj )
+ case 0 : // position in title area
{
- aOutlineRect = pOutlineObj->GetLogicRect();
- aOutlineSize = aOutlineRect.GetSize();
+ if ( aLogicRect != aTitleRect )
+ pPresObj->SetUserCall( nullptr );
}
- Rectangle aLogicRect( pPresObj->GetLogicRect() );
- Size aLogicSize( aLogicRect.GetSize() );
+ break;
- switch ( nPlacementId )
+ case 1:
{
- case 0 : // position in title area
- {
- if ( aLogicRect != aTitleRect )
+ if ( pSlideLayout->eLayout == PptSlideLayout::TITLEANDBODYSLIDE )
+ { // position in outline area
+ if ( aLogicRect != aOutlineRect )
pPresObj->SetUserCall( nullptr );
}
- break;
-
- case 1:
- {
- if ( pSlideLayout->eLayout == PptSlideLayout::TITLEANDBODYSLIDE )
- { // position in outline area
- if ( aLogicRect != aOutlineRect )
- pPresObj->SetUserCall( nullptr );
- }
- else if ( pSlideLayout->eLayout == PptSlideLayout::TWOCOLUMNSANDTITLE )
- { // position in outline area left
- if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
- (double)aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
- (double)aLogicSize.Width() / aOutlineSize.Width() > 0.5)
- {
- pPresObj->SetUserCall(nullptr);
- }
- }
- else if ( pSlideLayout->eLayout == PptSlideLayout::TWOROWSANDTITLE )
- { // position in outline area top
- if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
- {
- pPresObj->SetUserCall( nullptr );
- }
+ else if ( pSlideLayout->eLayout == PptSlideLayout::TWOCOLUMNSANDTITLE )
+ { // position in outline area left
+ if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
+ (double)aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
+ (double)aLogicSize.Width() / aOutlineSize.Width() > 0.5)
+ {
+ pPresObj->SetUserCall(nullptr);
}
- else if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
- { // position in outline area top left
+ }
+ else if ( pSlideLayout->eLayout == PptSlideLayout::TWOROWSANDTITLE )
+ { // position in outline area top
+ if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
+ {
pPresObj->SetUserCall( nullptr );
}
}
- break;
+ else if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
+ { // position in outline area top left
+ pPresObj->SetUserCall( nullptr );
+ }
+ }
+ break;
- case 2:
- {
- if ( pSlideLayout->eLayout == PptSlideLayout::TWOCOLUMNSANDTITLE )
- { // position in outline area right
- if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
- (double)aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
- (double)aLogicSize.Width() / aOutlineSize.Width() > 0.5)
- {
- pPresObj->SetUserCall( nullptr );
- }
- }
- else if ( pSlideLayout->eLayout == PptSlideLayout::TWOROWSANDTITLE )
- { // position in outline area bottom
- if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
- {
- pPresObj->SetUserCall( nullptr );
- }
- }
- else if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
- { // position in outline area top right
- pPresObj->SetUserCall(nullptr);
+ case 2:
+ {
+ if ( pSlideLayout->eLayout == PptSlideLayout::TWOCOLUMNSANDTITLE )
+ { // position in outline area right
+ if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
+ (double)aLogicSize.Width() / aOutlineSize.Width() < 0.48 ||
+ (double)aLogicSize.Width() / aOutlineSize.Width() > 0.5)
+ {
+ pPresObj->SetUserCall( nullptr );
}
}
- break;
-
- case 3:
- { // position in outline area bottom left
+ else if ( pSlideLayout->eLayout == PptSlideLayout::TWOROWSANDTITLE )
+ { // position in outline area bottom
if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
+ std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE)
{
pPresObj->SetUserCall( nullptr );
}
}
- break;
+ else if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Top() - aOutlineRect.Top()) > MAX_USER_MOVE)
+ { // position in outline area top right
+ pPresObj->SetUserCall(nullptr);
+ }
+ }
+ break;
- case 4:
- { // position in outline area bottom right
- if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
- std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
- {
- pObj->SetUserCall( nullptr );
- }
+ case 3:
+ { // position in outline area bottom left
+ if (std::abs(aLogicRect.Left() - aOutlineRect.Left()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
+ {
+ pPresObj->SetUserCall( nullptr );
}
- break;
}
+ break;
+
+ case 4:
+ { // position in outline area bottom right
+ if (std::abs(aLogicRect.Right() - aOutlineRect.Right()) > MAX_USER_MOVE ||
+ std::abs(aLogicRect.Bottom() - aOutlineRect.Bottom()) > MAX_USER_MOVE)
+ {
+ pObj->SetUserCall( nullptr );
+ }
+ }
+ break;
}
- pRet = nullptr; // return zero cause this obj was already inserted by CreatePresObj
}
+ pRet = nullptr; // return zero cause this obj was already inserted by CreatePresObj
}
- else if ( !pTextObj->Count() )
- pRet = nullptr;
}
+ else if ( !pTextObj->Count() )
+ pRet = nullptr;
}
}
}
More information about the Libreoffice-commits
mailing list