Kaydet (Commit) 554902ea authored tarafından Zolnai Tamás's avatar Zolnai Tamás

Make SdrGrafObj swapping methods private.

Plus remove some useless call of them.

Change the tests accordingly.

Change-Id: I47a50b5734d799ac02ee7221c95f82415afb9497
üst 9dc3b49c
...@@ -3970,7 +3970,6 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons ...@@ -3970,7 +3970,6 @@ SdrObject* SvxMSDffManager::ImportGraphic( SvStream& rSt, SfxItemSet& rSet, cons
if ( bLinkGrf && !bGrfRead ) if ( bLinkGrf && !bGrfRead )
{ {
static_cast<SdrGrafObj*>(pRet)->ForceSwapIn();
Graphic aGraf(static_cast<SdrGrafObj*>(pRet)->GetGraphic()); Graphic aGraf(static_cast<SdrGrafObj*>(pRet)->GetGraphic());
lcl_ApplyCropping( *this, &rSet, aGraf ); lcl_ApplyCropping( *this, &rSet, aGraf );
} }
......
...@@ -69,6 +69,7 @@ private: ...@@ -69,6 +69,7 @@ private:
// to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink() // to allow sdr::contact::ViewObjectContactOfGraphic access to ImpUpdateGraphicLink()
friend class sdr::contact::ViewObjectContactOfGraphic; friend class sdr::contact::ViewObjectContactOfGraphic;
friend class SdrExchangeView; // Only for a ForceSwapIn() call.
friend class SdrGraphicLink; friend class SdrGraphicLink;
private: private:
...@@ -135,9 +136,11 @@ public: ...@@ -135,9 +136,11 @@ public:
void SetGrafStreamURL( const OUString& rGraphicStreamURL ); void SetGrafStreamURL( const OUString& rGraphicStreamURL );
OUString GetGrafStreamURL() const; OUString GetGrafStreamURL() const;
private:
void ForceSwapIn() const; void ForceSwapIn() const;
void ForceSwapOut() const; void ForceSwapOut() const;
public:
void SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName); void SetGraphicLink(const OUString& rFileName, const OUString& rReferer, const OUString& rFilterName);
void ReleaseGraphicLink(); void ReleaseGraphicLink();
bool IsLinkedGraphic() const; bool IsLinkedGraphic() const;
......
...@@ -117,6 +117,10 @@ $(eval $(call gb_CppunitTest_use_components,sc_subsequent_export_test,\ ...@@ -117,6 +117,10 @@ $(eval $(call gb_CppunitTest_use_components,sc_subsequent_export_test,\
)) ))
endif endif
$(eval $(call gb_CppunitTest_use_custom_headers,sc_subsequent_export_test,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_configuration,sc_subsequent_export_test)) $(eval $(call gb_CppunitTest_use_configuration,sc_subsequent_export_test))
# vim: set noet sw=4 ts=4: # vim: set noet sw=4 ts=4:
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <officecfg/Office/Common.hxx>
#include <sal/config.h> #include <sal/config.h>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <osl/file.hxx> #include <osl/file.hxx>
...@@ -59,7 +60,7 @@ ...@@ -59,7 +60,7 @@
#include <tools/datetime.hxx> #include <tools/datetime.hxx>
#include <test/xmltesttools.hxx> #include <test/xmltesttools.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/table/BorderLineStyle.hpp> #include <com/sun/star/table/BorderLineStyle.hpp>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp> #include <com/sun/star/sheet/GeneralFunction.hpp>
...@@ -2271,26 +2272,19 @@ void ScExportTest::testSwappedOutImageExport() ...@@ -2271,26 +2272,19 @@ void ScExportTest::testSwappedOutImageExport()
"generic_HTML", "generic_HTML",
}; };
// Set cache size to a very small value to make sure one of the images is swapped out
boost::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), xBatch);
xBatch->commit();
for( size_t nFilter = 0; nFilter < aFilterNames.size(); ++nFilter ) for( size_t nFilter = 0; nFilter < aFilterNames.size(); ++nFilter )
{ {
// Check whether the export code swaps in the image which was swapped out before. // Check whether the export code swaps in the image which was swapped out before.
ScDocShellRef xDocSh = loadDoc("document_with_an_image.", ODS); ScDocShellRef xDocSh = loadDoc("document_with_two_images.", ODS);
const OString sFailedMessage = OString("Failed on filter: ") const OString sFailedMessage = OString("Failed on filter: ")
+ OUStringToOString(aFilterNames[nFilter], RTL_TEXTENCODING_ASCII_US); + OUStringToOString(aFilterNames[nFilter], RTL_TEXTENCODING_ASCII_US);
// Find and swap out the image
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDocSh.Is()); CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDocSh.Is());
ScDocument* pDoc = &xDocSh->GetDocument();
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc);
ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDrawLayer);
const SdrPage* pPage = pDrawLayer->GetPage(0);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pPage);
const SdrObject* pObj = pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObj->GetObjIdentifier() == OBJ_GRAF);
const SdrGrafObj& rGrafObj = static_cast<const SdrGrafObj&>(*pObj);
rGrafObj.ForceSwapOut();
// Export the document and import again for a check // Export the document and import again for a check
ScDocShellRef xDocSh2 = saveAndReload(xDocSh, nFilter); ScDocShellRef xDocSh2 = saveAndReload(xDocSh, nFilter);
...@@ -2302,7 +2296,7 @@ void ScExportTest::testSwappedOutImageExport() ...@@ -2302,7 +2296,7 @@ void ScExportTest::testSwappedOutImageExport()
uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xIA(xDoc->getSheets(), UNO_QUERY_THROW);
uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW); uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xIA->getByIndex(0), UNO_QUERY_THROW);
uno::Reference< container::XIndexAccess > xDraws(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW); uno::Reference< container::XIndexAccess > xDraws(xDrawPageSupplier->getDrawPage(), UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(1), xDraws->getCount()); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2), xDraws->getCount());
uno::Reference<drawing::XShape> xImage(xDraws->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XShape> xImage(xDraws->getByIndex(0), uno::UNO_QUERY);
uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > XPropSet( xImage, uno::UNO_QUERY_THROW );
...@@ -2322,6 +2316,24 @@ void ScExportTest::testSwappedOutImageExport() ...@@ -2322,6 +2316,24 @@ void ScExportTest::testSwappedOutImageExport()
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width ); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height ); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
} }
// Second Image
xImage.set(xDraws->getByIndex(1), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check URL
{
OUString sURL;
XPropSet->getPropertyValue("GraphicURL") >>= sURL;
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("vnd.sun.star.GraphicObject:1000000000000384000002580A24B597"), sURL);
}
// Check size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
}
xDocSh2->DoClose(); xDocSh2->DoClose();
} }
} }
......
...@@ -106,6 +106,10 @@ $(eval $(call gb_CppunitTest_use_components,sd_export_tests,\ ...@@ -106,6 +106,10 @@ $(eval $(call gb_CppunitTest_use_components,sd_export_tests,\
xmlsecurity/util/xmlsecurity \ xmlsecurity/util/xmlsecurity \
)) ))
$(eval $(call gb_CppunitTest_use_custom_headers,sd_export_tests,\
officecfg/registry \
))
$(eval $(call gb_CppunitTest_use_configuration,sd_export_tests)) $(eval $(call gb_CppunitTest_use_configuration,sd_export_tests))
$(eval $(call gb_CppunitTest_use_unittest_configuration,sd_export_tests)) $(eval $(call gb_CppunitTest_use_unittest_configuration,sd_export_tests))
......
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
#include <officecfg/Office/Common.hxx>
#include "sdmodeltestbase.hxx" #include "sdmodeltestbase.hxx"
#include "Outliner.hxx" #include "Outliner.hxx"
#include <comphelper/processfactory.hxx>
#include <svl/stritem.hxx> #include <svl/stritem.hxx>
#include <editeng/editobj.hxx> #include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx> #include <editeng/outlobj.hxx>
...@@ -504,21 +504,17 @@ void SdExportTest::testSwappedOutImageExport() ...@@ -504,21 +504,17 @@ void SdExportTest::testSwappedOutImageExport()
PPTX, PPTX,
}; };
// Set cache size to a very small value to make sure one of the images is swapped out
boost::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), xBatch);
xBatch->commit();
for( size_t nExportFormat = 0; nExportFormat < vFormats.size(); ++nExportFormat ) for( size_t nExportFormat = 0; nExportFormat < vFormats.size(); ++nExportFormat )
{ {
// Load the original file with one image // Load the original file with one image
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/document_with_an_image.odp"), ODP); ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/document_with_two_images.odp"), ODP);
const OString sFailedMessage = OString("Failed on filter: ") + OString(aFileFormats[nExportFormat].pFilterName); const OString sFailedMessage = OString("Failed on filter: ") + OString(aFileFormats[nExportFormat].pFilterName);
// Swap out the image
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pDoc != NULL );
const SdrPage* pPage = pDoc->GetPage(1);
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), pPage != NULL );
SdrGrafObj* pGrafObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pGrafObject != NULL);
pGrafObject->ForceSwapOut();
// Export the document and import again for a check // Export the document and import again for a check
uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), uno::UNO_QUERY); uno::Reference< lang::XComponent > xComponent(xDocShRef->GetModel(), uno::UNO_QUERY);
uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY); uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
...@@ -534,7 +530,7 @@ void SdExportTest::testSwappedOutImageExport() ...@@ -534,7 +530,7 @@ void SdExportTest::testSwappedOutImageExport()
// Check whether graphic exported well after it was swapped out // Check whether graphic exported well after it was swapped out
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), xDrawPagesSupplier->getDrawPages()->getCount() == 1 ); CPPUNIT_ASSERT_MESSAGE( sFailedMessage.getStr(), xDrawPagesSupplier->getDrawPages()->getCount() == 2 );
uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW ); uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY); uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
...@@ -554,6 +550,26 @@ void SdExportTest::testSwappedOutImageExport() ...@@ -554,6 +550,26 @@ void SdExportTest::testSwappedOutImageExport()
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width ); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height ); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381), xBitmap->getSize().Height );
} }
// Second Image
xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
XPropSet.set( xImage, uno::UNO_QUERY_THROW );
// Check URL
{
OUString sURL;
XPropSet->getPropertyValue("GraphicURL") >>= sURL;
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), OUString("vnd.sun.star.GraphicObject:1000000000000384000002580A24B597"), sURL);
}
// Check size
{
uno::Reference<graphic::XGraphic> xGraphic;
XPropSet->getPropertyValue("Graphic") >>= xGraphic;
uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900), xBitmap->getSize().Width );
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600), xBitmap->getSize().Height );
}
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
} }
......
...@@ -245,8 +245,6 @@ namespace sdr ...@@ -245,8 +245,6 @@ namespace sdr
// prepare primitive generation with evtl. loading the graphic when it's swapped out // prepare primitive generation with evtl. loading the graphic when it's swapped out
SdrGrafObj& rGrafObj = const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj(); SdrGrafObj& rGrafObj = const_cast< ViewObjectContactOfGraphic* >(this)->getSdrGrafObj();
bool bDoAsynchronGraphicLoading(rGrafObj.GetModel() && rGrafObj.GetModel()->IsSwapGraphics()); bool bDoAsynchronGraphicLoading(rGrafObj.GetModel() && rGrafObj.GetModel()->IsSwapGraphics());
bool bSwapInDone(false);
bool bSwapInExclusive(false);
if( bDoAsynchronGraphicLoading && rGrafObj.IsSwappedOut() ) if( bDoAsynchronGraphicLoading && rGrafObj.IsSwappedOut() )
{ {
...@@ -262,16 +260,15 @@ namespace sdr ...@@ -262,16 +260,15 @@ namespace sdr
|| GetObjectContact().isOutputToPDFFile() ) || GetObjectContact().isOutputToPDFFile() )
{ {
bDoAsynchronGraphicLoading = false; bDoAsynchronGraphicLoading = false;
bSwapInExclusive = true;
} }
} }
if( bDoAsynchronGraphicLoading ) if( bDoAsynchronGraphicLoading )
{ {
bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithAsynchroniousLoading(); const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithAsynchroniousLoading();
} }
else else
{ {
bSwapInDone = const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithSynchroniousLoading(); const_cast< ViewObjectContactOfGraphic* >(this)->impPrepareGraphicWithSynchroniousLoading();
} }
// get return value by calling parent // get return value by calling parent
...@@ -294,12 +291,6 @@ namespace sdr ...@@ -294,12 +291,6 @@ namespace sdr
} }
} }
// if swap in was forced only for printing metafile and pdf, swap out again
if( bSwapInDone && bSwapInExclusive )
{
rGrafObj.ForceSwapOut();
}
return xRetval; return xRetval;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment