summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <Thorsten.Behrens@CIB.de>2016-03-20 01:12:56 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2016-03-20 01:12:56 +0100
commit3445fb9326fb632498cf2123aa1213be40e789c1 (patch)
treee4465f3e97c017128c2002abe2ef5d42a5033fc7
parent1d5767c6e464b914812867aac5c3ccd0745dd1ea (diff)
Revert "tdf#93124: Fix incorrect text fit in imported PPT"
Change broke autofit feature, see bugreport. This reverts commit 5ca1f04976930c6fd656ebf89d667c80e2466897.
-rw-r--r--filter/source/msfilter/svdfppt.cxx126
-rw-r--r--sd/CppunitTest_sd_import_tests.mk1
-rw-r--r--sd/qa/unit/data/ppt/tdf93124.pptbin85504 -> 0 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx51
4 files changed, 90 insertions, 88 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 7765dac96aeb..ebea1c297280 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -893,6 +893,31 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
eTHA = SDRTEXTHORZADJUST_LEFT;
break;
}
+ // if there is a 100% use of following attributes, the textbox can been aligned also in vertical direction
+ switch ( eTextAnchor )
+ {
+ case mso_anchorTopCentered :
+ case mso_anchorMiddleCentered :
+ case mso_anchorBottomCentered :
+ case mso_anchorTopCenteredBaseline:
+ case mso_anchorBottomCenteredBaseline:
+ {
+ // check if it is sensible to use the centered alignment
+ sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
+ if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
+ eTVA = SDRTEXTVERTADJUST_CENTER; // the text has to be displayed using the full width;
+ }
+ break;
+
+ default :
+ {
+ if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
+ eTVA = SDRTEXTVERTADJUST_TOP;
+ else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
+ eTVA = SDRTEXTVERTADJUST_BOTTOM;
+ }
+ break;
+ }
nMinFrameWidth = rTextRect.GetWidth() - ( nTextLeft + nTextRight );
}
else
@@ -924,6 +949,31 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
eTVA = SDRTEXTVERTADJUST_BOTTOM;
break;
}
+ // if there is a 100% usage of following attributes, the textbox can be aligned also in horizontal direction
+ switch ( eTextAnchor )
+ {
+ case mso_anchorTopCentered :
+ case mso_anchorMiddleCentered :
+ case mso_anchorBottomCentered :
+ case mso_anchorTopCenteredBaseline:
+ case mso_anchorBottomCenteredBaseline:
+ {
+ // check if it is sensible to use the centered alignment
+ sal_uInt32 nMask = PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT | PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT;
+ if ( ( nTextFlags & nMask ) != nMask ) // if the textobject has left and also right aligned pararagraphs
+ eTHA = SDRTEXTHORZADJUST_CENTER; // the text has to be displayed using the full width;
+ }
+ break;
+
+ default :
+ {
+ if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_LEFT )
+ eTHA = SDRTEXTHORZADJUST_LEFT;
+ else if ( nTextFlags == PPT_TEXTOBJ_FLAGS_PARA_ALIGNMENT_USED_RIGHT )
+ eTHA = SDRTEXTHORZADJUST_RIGHT;
+ }
+ break;
+ }
nMinFrameHeight = rTextRect.GetHeight() - ( nTextTop + nTextBottom );
}
@@ -971,6 +1021,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
}
aTextObj.SetDestinationInstance( (sal_uInt16)nDestinationInstance );
+ bool bAutoFit = false; // auto-scale text into shape box
switch ( aTextObj.GetInstance() )
{
case TSS_TYPE_PAGETITLE :
@@ -978,7 +1029,7 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
case TSS_TYPE_SUBTITLE : eTextKind = OBJ_TEXT; break;
case TSS_TYPE_BODY :
case TSS_TYPE_HALFBODY :
- case TSS_TYPE_QUARTERBODY : eTextKind = OBJ_OUTLINETEXT; break;
+ case TSS_TYPE_QUARTERBODY : eTextKind = OBJ_OUTLINETEXT; bAutoFit = true; break;
}
if ( aTextObj.GetDestinationInstance() != TSS_TYPE_TEXT_IN_SHAPE )
{
@@ -1037,44 +1088,47 @@ SdrObject* SdrEscherImport::ProcessObj( SvStream& rSt, DffObjData& rObjData, voi
}
pTObj->SetMergedItem( SvxFrameDirectionItem( bVerticalText ? FRMDIR_VERT_TOP_RIGHT : FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
- // SdStyleSheetPool::CreateLayoutStyleSheets in stlpool.cxx applies SDRTEXTFIT_AUTOFIT by default,
- // so need to override here
- pTObj->SetMergedItem(SdrTextFitToSizeTypeItem(SDRTEXTFIT_NONE));
-
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
- {
- pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
- pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
- }
- else
+ //Autofit text only if there is no auto grow height and width
+ //See fdo#41245
+ if (bAutoFit && !bAutoGrowHeight && !bAutoGrowWidth)
{
- pTObj->SetMergedItem( makeSdrTextWordWrapItem( bWordWrap ) );
- pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bFitShapeToText ) );
+ pTObj->SetMergedItem( SdrTextFitToSizeTypeItem(SDRTEXTFIT_AUTOFIT) );
}
- pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
- pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ {
+ pTObj->SetMergedItem( makeSdrTextAutoGrowWidthItem( bAutoGrowWidth ) );
+ pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bAutoGrowHeight ) );
+ }
+ else
+ {
+ pTObj->SetMergedItem( makeSdrTextWordWrapItem( bWordWrap ) );
+ pTObj->SetMergedItem( makeSdrTextAutoGrowHeightItem( bFitShapeToText ) );
+ }
+
+ pTObj->SetMergedItem( SdrTextVertAdjustItem( eTVA ) );
+ pTObj->SetMergedItem( SdrTextHorzAdjustItem( eTHA ) );
- if ( nMinFrameHeight < 0 )
- nMinFrameHeight = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
- pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
+ if ( nMinFrameHeight < 0 )
+ nMinFrameHeight = 0;
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ pTObj->SetMergedItem( makeSdrTextMinFrameHeightItem( nMinFrameHeight ) );
- if ( nMinFrameWidth < 0 )
- nMinFrameWidth = 0;
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
- pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
+ if ( nMinFrameWidth < 0 )
+ nMinFrameWidth = 0;
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ pTObj->SetMergedItem( makeSdrTextMinFrameWidthItem( nMinFrameWidth ) );
- // set margins at the borders of the textbox
- pTObj->SetMergedItem( makeSdrTextLeftDistItem( nTextLeft ) );
- pTObj->SetMergedItem( makeSdrTextRightDistItem( nTextRight ) );
- pTObj->SetMergedItem( makeSdrTextUpperDistItem( nTextTop ) );
- pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
- pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
+ // set margins at the borders of the textbox
+ pTObj->SetMergedItem( makeSdrTextLeftDistItem( nTextLeft ) );
+ pTObj->SetMergedItem( makeSdrTextRightDistItem( nTextRight ) );
+ pTObj->SetMergedItem( makeSdrTextUpperDistItem( nTextTop ) );
+ pTObj->SetMergedItem( makeSdrTextLowerDistItem( nTextBottom ) );
+ pTObj->SetMergedItem( SdrTextFixedCellHeightItem( true ) );
- if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
- pTObj->SetSnapRect( rTextRect );
- pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
+ if ( dynamic_cast<const SdrObjCustomShape* >(pTObj) == nullptr )
+ pTObj->SetSnapRect( rTextRect );
+ pTObj = ReadObjText( &aTextObj, pTObj, rData.pPage );
if ( pTObj )
{
@@ -1339,7 +1393,7 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
if ( pPersistPtr[ nOfs ] > nStreamLen )
{
bOk = false;
- OSL_FAIL("SdrPowerPointImport::Ctor(): Invalid entry in Persist-Directory!");
+ OSL_FAIL("SdrPowerPointImport::Ctor(): Ungueltiger Eintrag im Persist-Directory!");
}
}
nAnz--;
@@ -1347,7 +1401,7 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
}
if ( bOk && nAnz > 0 )
{
- OSL_FAIL("SdrPowerPointImport::Ctor(): Not all Persist-Directory entries read!");
+ OSL_FAIL("SdrPowerPointImport::Ctor(): Nicht alle Persist-Directory Entraege gelesen!");
bOk = false;
}
}
@@ -1369,7 +1423,7 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
nDocStreamPos = aUserEditAtom.nDocumentRef;
if ( nDocStreamPos > nPersistPtrAnz )
{
- OSL_FAIL("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef is invalid!");
+ OSL_FAIL("SdrPowerPointImport::Ctor(): aUserEditAtom.nDocumentRef ungueltig!");
bOk = false;
}
}
@@ -1561,7 +1615,7 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
}
else
{
- OSL_FAIL("SdrPowerPointImport::Ctor(): Persist-Entry is faulty! (SJ)");
+ OSL_FAIL("SdrPowerPointImport::Ctor(): Persist-Eintrag fehlerhaft! (SJ)");
}
}
}
diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk
index 33a7ad28d463..6058e8e58cfc 100644
--- a/sd/CppunitTest_sd_import_tests.mk
+++ b/sd/CppunitTest_sd_import_tests.mk
@@ -96,7 +96,6 @@ $(eval $(call gb_CppunitTest_use_components,sd_import_tests,\
sot/util/sot \
svl/source/fsstor/fsstorage \
svtools/util/svt \
- svx/util/svxcore \
toolkit/util/tk \
ucb/source/core/ucb1 \
ucb/source/ucp/expand/ucpexpand1 \
diff --git a/sd/qa/unit/data/ppt/tdf93124.ppt b/sd/qa/unit/data/ppt/tdf93124.ppt
deleted file mode 100644
index fad847898cc6..000000000000
--- a/sd/qa/unit/data/ppt/tdf93124.ppt
+++ /dev/null
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 29bcc05024be..b1023968ebe6 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -41,11 +41,9 @@
#include <animations/animationnodehelper.hxx>
#include <sax/tools/converter.hxx>
-#include <comphelper/processfactory.hxx>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
-#include <com/sun/star/drawing/GraphicExportFilter.hpp>
#include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
#include <com/sun/star/animations/XAnimationNode.hpp>
#include <com/sun/star/animations/XAnimate.hpp>
@@ -64,8 +62,6 @@
#include <com/sun/star/table/XTableRows.hpp>
#include <stlpool.hxx>
-#include <vcl/pngread.hxx>
-#include <vcl/bitmapaccess.hxx>
using namespace ::com::sun::star;
@@ -114,7 +110,6 @@ public:
void testTdf93097();
void testTdf62255();
void testTdf89927();
- void testTdf93124();
CPPUNIT_TEST_SUITE(SdImportTest);
@@ -159,7 +154,6 @@ public:
CPPUNIT_TEST(testTdf93097);
CPPUNIT_TEST(testTdf62255);
CPPUNIT_TEST(testTdf89927);
- CPPUNIT_TEST(testTdf93124);
CPPUNIT_TEST_SUITE_END();
};
@@ -1225,51 +1219,6 @@ void SdImportTest::testTdf89927()
xDocShRef->DoClose();
}
-void SdImportTest::testTdf93124()
-{
- sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT);
- uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
- uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
-
- uno::Sequence< beans::PropertyValue > aFilterData(2);
- aFilterData[0].Name = "PixelWidth";
- aFilterData[0].Value <<= (sal_Int32)(320);
- aFilterData[1].Name = "PixelHeight";
- aFilterData[1].Value <<= (sal_Int32)(180);
-
- utl::TempFile aTempFile;
- aTempFile.EnableKillingFile();
-
- uno::Sequence< beans::PropertyValue > aDescriptor(3);
- aDescriptor[0].Name = "URL";
- aDescriptor[0].Value <<= aTempFile.GetURL();
- aDescriptor[1].Name = "FilterName";
- aDescriptor[1].Value <<= OUString("PNG");
- aDescriptor[2].Name = "FilterData";
- aDescriptor[2].Value <<= aFilterData;
-
- uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
- xGraphicExporter->setSourceDocument(xPage);
- xGraphicExporter->filter(aDescriptor);
-
- SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
- vcl::PNGReader aPNGReader(aFileStream);
- BitmapEx aBMPEx = aPNGReader.Read();
- Bitmap aBMP = aBMPEx.GetBitmap();
- BitmapReadAccess* pRead = aBMP.AcquireReadAccess();
- int nNonWhiteCount = 0;
- // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white.
- for (long nX = 34; nX < (34 + 43); ++nX)
- for (long nY = 4; nY < (4 + 26); ++nY)
- {
- const Color aColor = pRead->GetColor(nY, nX);
- if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
- ++nNonWhiteCount;
- }
- CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>100);
- xDocShRef->DoClose();
-}
-
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();