Kaydet (Commit) d1bc69ad authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Michael Meeks

CppunitTest_desktop_lib: close the document while LOK is still active

Otherwise the LOK notifiers won't be released (since LOK is not active),
and we leak vcl::Windows in GetLOKWindowsMap()::s_pLOKWindowsMap.

In dbgutil builds, this leads to an assertion failure if the sidebar is
active.

(cherry picked from commit da17ccae)

On cp-6.0, this is a regression from the cp-6.0-only commit
49fe72fe (sfx2: LOK: route the parent
sidebar window instead of the deck, 2018-10-10).

Conflicts:
	desktop/qa/desktop_lib/test_desktop_lib.cxx

Change-Id: Idedb9578478ff4a9f2e17c0cfd203da6f007bdbd
Reviewed-on: https://gerrit.libreoffice.org/72098Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst a81b7eba
...@@ -76,7 +76,11 @@ public: ...@@ -76,7 +76,11 @@ public:
virtual void tearDown() override virtual void tearDown() override
{ {
if (m_pDocument)
m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, nullptr);
closeDoc(); closeDoc();
comphelper::LibreOfficeKit::setActive(false);
UnoApiTest::tearDown(); UnoApiTest::tearDown();
}; };
...@@ -211,6 +215,7 @@ public: ...@@ -211,6 +215,7 @@ public:
osl::Condition m_aContextMenuCondition; osl::Condition m_aContextMenuCondition;
boost::property_tree::ptree m_aContextMenuResult; boost::property_tree::ptree m_aContextMenuResult;
std::unique_ptr<LibLODocument_Impl> m_pDocument;
}; };
static Control* GetFocusControl(vcl::Window const * pParent) static Control* GetFocusControl(vcl::Window const * pParent)
...@@ -255,7 +260,8 @@ LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDoc ...@@ -255,7 +260,8 @@ LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDoc
{ {
CPPUNIT_ASSERT(false); CPPUNIT_ASSERT(false);
} }
return new LibLODocument_Impl(mxComponent); m_pDocument.reset(new LibLODocument_Impl(mxComponent));
return m_pDocument.get();
} }
void DesktopLOKTest::closeDoc() void DesktopLOKTest::closeDoc()
...@@ -367,7 +373,6 @@ void DesktopLOKTest::testGetStyles() ...@@ -367,7 +373,6 @@ void DesktopLOKTest::testGetStyles()
CPPUNIT_FAIL("Unknown style family: " + rPair.first); CPPUNIT_FAIL("Unknown style family: " + rPair.first);
} }
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testGetFonts() void DesktopLOKTest::testGetFonts()
...@@ -389,7 +394,6 @@ void DesktopLOKTest::testGetFonts() ...@@ -389,7 +394,6 @@ void DesktopLOKTest::testGetFonts()
CPPUNIT_ASSERT( rPair.second.size() > 0); CPPUNIT_ASSERT( rPair.second.size() > 0);
} }
free(pJSON); free(pJSON);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testCreateView() void DesktopLOKTest::testCreateView()
...@@ -416,7 +420,6 @@ void DesktopLOKTest::testCreateView() ...@@ -416,7 +420,6 @@ void DesktopLOKTest::testCreateView()
pDocument->m_pDocumentClass->destroyView(pDocument, nId1); pDocument->m_pDocumentClass->destroyView(pDocument, nId1);
CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument)); CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testGetPartPageRectangles() void DesktopLOKTest::testGetPartPageRectangles()
...@@ -440,7 +443,6 @@ void DesktopLOKTest::testGetPartPageRectangles() ...@@ -440,7 +443,6 @@ void DesktopLOKTest::testGetPartPageRectangles()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRectangles.size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aRectangles.size());
free(pRectangles); free(pRectangles);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testGetFilterTypes() void DesktopLOKTest::testGetFilterTypes()
...@@ -456,7 +458,6 @@ void DesktopLOKTest::testGetFilterTypes() ...@@ -456,7 +458,6 @@ void DesktopLOKTest::testGetFilterTypes()
CPPUNIT_ASSERT(aTree.size() > 0); CPPUNIT_ASSERT(aTree.size() > 0);
CPPUNIT_ASSERT_EQUAL(std::string("application/vnd.oasis.opendocument.text"), aTree.get_child("writer8").get_child("MediaType").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(std::string("application/vnd.oasis.opendocument.text"), aTree.get_child("writer8").get_child("MediaType").get_value<std::string>());
free(pJSON); free(pJSON);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSearchCalc() void DesktopLOKTest::testSearchCalc()
...@@ -490,8 +491,6 @@ void DesktopLOKTest::testSearchCalc() ...@@ -490,8 +491,6 @@ void DesktopLOKTest::testSearchCalc()
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), m_aSearchResultSelection.size());
// Result is on the first sheet. // Result is on the first sheet.
CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]); CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSearchAllNotificationsCalc() void DesktopLOKTest::testSearchAllNotificationsCalc()
...@@ -516,8 +515,6 @@ void DesktopLOKTest::testSearchAllNotificationsCalc() ...@@ -516,8 +515,6 @@ void DesktopLOKTest::testSearchAllNotificationsCalc()
CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult);
// But we do get the selection afterwards. // But we do get the selection afterwards.
CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0); CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testPaintTile() void DesktopLOKTest::testPaintTile()
...@@ -546,8 +543,6 @@ void DesktopLOKTest::testPaintTile() ...@@ -546,8 +543,6 @@ void DesktopLOKTest::testPaintTile()
nTileHeight = 4000; nTileHeight = 4000;
aBuffer.resize(nCanvasWidth * nCanvasHeight * 4); aBuffer.resize(nCanvasWidth * nCanvasHeight * 4);
pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); pDocument->pClass->paintTile(pDocument, aBuffer.data(), nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSaveAs() void DesktopLOKTest::testSaveAs()
...@@ -558,8 +553,6 @@ void DesktopLOKTest::testSaveAs() ...@@ -558,8 +553,6 @@ void DesktopLOKTest::testSaveAs()
utl::TempFile aTempFile; utl::TempFile aTempFile;
aTempFile.EnableKillingFile(); aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr)); CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSaveAsCalc() void DesktopLOKTest::testSaveAsCalc()
...@@ -570,8 +563,6 @@ void DesktopLOKTest::testSaveAsCalc() ...@@ -570,8 +563,6 @@ void DesktopLOKTest::testSaveAsCalc()
utl::TempFile aTempFile; utl::TempFile aTempFile;
aTempFile.EnableKillingFile(); aTempFile.EnableKillingFile();
CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr)); CPPUNIT_ASSERT(pDocument->pClass->saveAs(pDocument, aTempFile.GetURL().toUtf8().getStr(), "png", nullptr));
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testPasteWriter() void DesktopLOKTest::testPasteWriter()
...@@ -593,8 +584,6 @@ void DesktopLOKTest::testPasteWriter() ...@@ -593,8 +584,6 @@ void DesktopLOKTest::testPasteWriter()
CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength())); CPPUNIT_ASSERT(!pDocument->pClass->paste(pDocument, "textt/plain;charset=utf-8", aText.getStr(), aText.getLength()));
// Writer is expected to support text/html. // Writer is expected to support text/html.
CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength())); CPPUNIT_ASSERT(pDocument->pClass->paste(pDocument, "text/html", aText.getStr(), aText.getLength()));
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testPasteWriterJPEG() void DesktopLOKTest::testPasteWriterJPEG()
...@@ -629,8 +618,6 @@ void DesktopLOKTest::testPasteWriterJPEG() ...@@ -629,8 +618,6 @@ void DesktopLOKTest::testPasteWriterJPEG()
xShape.set(xDrawPage->getByIndex(0), uno::UNO_QUERY); xShape.set(xDrawPage->getByIndex(0), uno::UNO_QUERY);
// This was text::TextContentAnchorType_AS_CHARACTER, AnchorType argument was ignored. // This was text::TextContentAnchorType_AS_CHARACTER, AnchorType argument was ignored.
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>()); CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, xShape->getPropertyValue("AnchorType").get<text::TextContentAnchorType>());
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testUndoWriter() void DesktopLOKTest::testUndoWriter()
...@@ -651,8 +638,6 @@ void DesktopLOKTest::testUndoWriter() ...@@ -651,8 +638,6 @@ void DesktopLOKTest::testUndoWriter()
boost::property_tree::read_json(aStream, aTree); boost::property_tree::read_json(aStream, aTree);
// Make sure that pressing a key creates exactly one undo action. // Make sure that pressing a key creates exactly one undo action.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("actions").size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("actions").size());
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testRowColumnHeaders() void DesktopLOKTest::testRowColumnHeaders()
...@@ -765,8 +750,6 @@ void DesktopLOKTest::testRowColumnHeaders() ...@@ -765,8 +750,6 @@ void DesktopLOKTest::testRowColumnHeaders()
nPrevious = nSize; nPrevious = nSize;
} }
CPPUNIT_ASSERT(!bNotEnoughHeaders); CPPUNIT_ASSERT(!bNotEnoughHeaders);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testHiddenRowHeaders() void DesktopLOKTest::testHiddenRowHeaders()
...@@ -807,7 +790,6 @@ void DesktopLOKTest::testHiddenRowHeaders() ...@@ -807,7 +790,6 @@ void DesktopLOKTest::testHiddenRowHeaders()
} }
nPrevious = nSize; nPrevious = nSize;
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testCellCursor() void DesktopLOKTest::testCellCursor()
...@@ -829,8 +811,6 @@ void DesktopLOKTest::testCellCursor() ...@@ -829,8 +811,6 @@ void DesktopLOKTest::testCellCursor()
OString aRectangle(aTree.get<std::string>("commandValues").c_str()); OString aRectangle(aTree.get<std::string>("commandValues").c_str());
// cell cursor geometry + col + row // cell cursor geometry + col + row
CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle); CPPUNIT_ASSERT_EQUAL(OString("0, 0, 1274, 254, 0, 0"), aRectangle);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testCommandResult() void DesktopLOKTest::testCommandResult()
...@@ -867,8 +847,6 @@ void DesktopLOKTest::testCommandResult() ...@@ -867,8 +847,6 @@ void DesktopLOKTest::testCommandResult()
CPPUNIT_ASSERT_EQUAL(aTree.get_child("commandName").get_value<std::string>(), std::string(".uno:Bold")); CPPUNIT_ASSERT_EQUAL(aTree.get_child("commandName").get_value<std::string>(), std::string(".uno:Bold"));
CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true); CPPUNIT_ASSERT_EQUAL(aTree.get_child("success").get_value<bool>(), true);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testWriterComments() void DesktopLOKTest::testWriterComments()
...@@ -910,8 +888,6 @@ void DesktopLOKTest::testWriterComments() ...@@ -910,8 +888,6 @@ void DesktopLOKTest::testWriterComments()
auto xTextField = xTextPortion->getPropertyValue("TextField").get< uno::Reference<beans::XPropertySet> >(); auto xTextField = xTextPortion->getPropertyValue("TextField").get< uno::Reference<beans::XPropertySet> >();
// This was empty, typed characters ended up in the body text. // This was empty, typed characters ended up in the body text.
CPPUNIT_ASSERT_EQUAL(OUString("test"), xTextField->getPropertyValue("Content").get<OUString>()); CPPUNIT_ASSERT_EQUAL(OUString("test"), xTextField->getPropertyValue("Content").get<OUString>());
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testTrackChanges() void DesktopLOKTest::testTrackChanges()
...@@ -934,8 +910,6 @@ void DesktopLOKTest::testTrackChanges() ...@@ -934,8 +910,6 @@ void DesktopLOKTest::testTrackChanges()
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
// This was 1, only the active view was notified. // This was 1, only the active view was notified.
CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges); CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSheetOperations() void DesktopLOKTest::testSheetOperations()
...@@ -968,8 +942,6 @@ void DesktopLOKTest::testSheetOperations() ...@@ -968,8 +942,6 @@ void DesktopLOKTest::testSheetOperations()
{ {
CPPUNIT_ASSERT_EQUAL(aExpected[i], OString(pDocument->pClass->getPartName(pDocument, i))); CPPUNIT_ASSERT_EQUAL(aExpected[i], OString(pDocument->pClass->getPartName(pDocument, i)));
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSheetSelections() void DesktopLOKTest::testSheetSelections()
...@@ -1081,8 +1053,6 @@ void DesktopLOKTest::testSheetSelections() ...@@ -1081,8 +1053,6 @@ void DesktopLOKTest::testSheetSelections()
free(pUsedMimeType); free(pUsedMimeType);
free(pCopiedContent); free(pCopiedContent);
} }
comphelper::LibreOfficeKit::setActive(false);
} }
namespace { namespace {
...@@ -1263,8 +1233,6 @@ void DesktopLOKTest::testContextMenuCalc() ...@@ -1263,8 +1233,6 @@ void DesktopLOKTest::testContextMenuCalc()
CPPUNIT_ASSERT(aCheckedToCell); CPPUNIT_ASSERT(aCheckedToCell);
CPPUNIT_ASSERT_EQUAL(std::string(aCheckedToCell.get().data()), std::string("false")); CPPUNIT_ASSERT_EQUAL(std::string(aCheckedToCell.get().data()), std::string("false"));
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testContextMenuWriter() void DesktopLOKTest::testContextMenuWriter()
...@@ -1320,8 +1288,6 @@ void DesktopLOKTest::testContextMenuWriter() ...@@ -1320,8 +1288,6 @@ void DesktopLOKTest::testContextMenuWriter()
CPPUNIT_ASSERT(aEnabled); CPPUNIT_ASSERT(aEnabled);
CPPUNIT_ASSERT_EQUAL(std::string(aEnabled.get().data()), std::string("true")); CPPUNIT_ASSERT_EQUAL(std::string(aEnabled.get().data()), std::string("true"));
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testContextMenuImpress() void DesktopLOKTest::testContextMenuImpress()
...@@ -1448,8 +1414,6 @@ void DesktopLOKTest::testContextMenuImpress() ...@@ -1448,8 +1414,6 @@ void DesktopLOKTest::testContextMenuImpress()
CPPUNIT_ASSERT(aCheckedHelpFront); CPPUNIT_ASSERT(aCheckedHelpFront);
CPPUNIT_ASSERT_EQUAL(std::string(aCheckedHelpFront.get().data()), std::string("true")); CPPUNIT_ASSERT_EQUAL(std::string(aCheckedHelpFront.get().data()), std::string("true"));
} }
comphelper::LibreOfficeKit::setActive(false);
} }
static void callbackCompressionTest(const int type, const char* payload, void* data) static void callbackCompressionTest(const int type, const char* payload, void* data)
...@@ -1544,8 +1508,6 @@ void DesktopLOKTest::testNotificationCompression() ...@@ -1544,8 +1508,6 @@ void DesktopLOKTest::testNotificationCompression()
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), std::get<1>(notifs[i++])); CPPUNIT_ASSERT_EQUAL(std::string(".uno:AssignLayout=1"), std::get<1>(notifs[i++]));
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testTileInvalidationCompression() void DesktopLOKTest::testTileInvalidationCompression()
...@@ -1683,8 +1645,6 @@ void DesktopLOKTest::testTileInvalidationCompression() ...@@ -1683,8 +1645,6 @@ void DesktopLOKTest::testTileInvalidationCompression()
CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, std::get<0>(notifs[i]));
CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1000000000, 1000000000, 0"), std::get<1>(notifs[i++])); CPPUNIT_ASSERT_EQUAL(std::string("0, 0, 1000000000, 1000000000, 0"), std::get<1>(notifs[i++]));
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testPartInInvalidation() void DesktopLOKTest::testPartInInvalidation()
...@@ -1758,8 +1718,6 @@ void DesktopLOKTest::testPartInInvalidation() ...@@ -1758,8 +1718,6 @@ void DesktopLOKTest::testPartInInvalidation()
// payload, so this was merged -> it was 1. // payload, so this was merged -> it was 1.
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), notifs.size());
} }
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testRedlineWriter() void DesktopLOKTest::testRedlineWriter()
...@@ -1789,8 +1747,6 @@ void DesktopLOKTest::testRedlineWriter() ...@@ -1789,8 +1747,6 @@ void DesktopLOKTest::testRedlineWriter()
CPPUNIT_ASSERT_EQUAL(std::string("Insert \xE2\x80\x9Ct\xE2\x80\x9D"), rRedline.second.get<std::string>("description")); CPPUNIT_ASSERT_EQUAL(std::string("Insert \xE2\x80\x9Ct\xE2\x80\x9D"), rRedline.second.get<std::string>("description"));
// U+201C LEFT DOUBLE QUOTATION MARK, U+201D RIGHT DOUBLE QUOTATION // U+201C LEFT DOUBLE QUOTATION MARK, U+201D RIGHT DOUBLE QUOTATION
// MARK // MARK
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testRedlineCalc() void DesktopLOKTest::testRedlineCalc()
...@@ -1820,8 +1776,6 @@ void DesktopLOKTest::testRedlineCalc() ...@@ -1820,8 +1776,6 @@ void DesktopLOKTest::testRedlineCalc()
for (boost::property_tree::ptree::value_type& rRedline : aTree.get_child("redlines")) for (boost::property_tree::ptree::value_type& rRedline : aTree.get_child("redlines"))
// This failed with boost::property_tree::ptree_bad_path, as there were no description field. // This failed with boost::property_tree::ptree_bad_path, as there were no description field.
CPPUNIT_ASSERT_EQUAL(std::string("Cell B4 changed from '5' to 't'"), rRedline.second.get<std::string>("description")); CPPUNIT_ASSERT_EQUAL(std::string("Cell B4 changed from '5' to 't'"), rRedline.second.get<std::string>("description"));
comphelper::LibreOfficeKit::setActive(false);
} }
class ViewCallback class ViewCallback
...@@ -1882,8 +1836,7 @@ void DesktopLOKTest::testPaintPartTile() ...@@ -1882,8 +1836,7 @@ void DesktopLOKTest::testPaintPartTile()
ViewCallback aView1; ViewCallback aView1;
ViewCallback aView2; ViewCallback aView2;
std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("2slides.odp")); LibLODocument_Impl* pDocument = loadDoc("2slides.odp");
LibLODocument_Impl* pDocument = xDocument.get();
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
int nView1 = pDocument->m_pDocumentClass->getView(pDocument); int nView1 = pDocument->m_pDocumentClass->getView(pDocument);
...@@ -1917,10 +1870,6 @@ void DesktopLOKTest::testPaintPartTile() ...@@ -1917,10 +1870,6 @@ void DesktopLOKTest::testPaintPartTile()
// This failed: paintPartTile() (as a side-effect) ended the text edit of // This failed: paintPartTile() (as a side-effect) ended the text edit of
// the first view, so there were no invalidations. // the first view, so there were no invalidations.
//CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); //CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testWriterCommentInsertCursor() void DesktopLOKTest::testWriterCommentInsertCursor()
...@@ -1930,8 +1879,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor() ...@@ -1930,8 +1879,7 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
ViewCallback aView1; ViewCallback aView1;
ViewCallback aView2; ViewCallback aView2;
std::unique_ptr<LibLODocument_Impl> xDocument(loadDoc("blank_text.odt")); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
LibLODocument_Impl* pDocument = xDocument.get();
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1);
pDocument->m_pDocumentClass->createView(pDocument); pDocument->m_pDocumentClass->createView(pDocument);
...@@ -1960,9 +1908,6 @@ void DesktopLOKTest::testWriterCommentInsertCursor() ...@@ -1960,9 +1908,6 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty()); CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty());
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
mxComponent.clear();
comphelper::LibreOfficeKit::setActive(false);
} }
#if HAVE_MORE_FONTS #if HAVE_MORE_FONTS
...@@ -1987,8 +1932,6 @@ void DesktopLOKTest::testGetFontSubset() ...@@ -1987,8 +1932,6 @@ void DesktopLOKTest::testGetFontSubset()
boost::property_tree::ptree aValues = aTree.get_child("commandValues"); boost::property_tree::ptree aValues = aTree.get_child("commandValues");
CPPUNIT_ASSERT( aValues.size() > 0 ); CPPUNIT_ASSERT( aValues.size() > 0 );
free(pJSON); free(pJSON);
comphelper::LibreOfficeKit::setActive(false);
} }
#endif #endif
...@@ -2042,7 +1985,6 @@ void DesktopLOKTest::testCommentsWriter() ...@@ -2042,7 +1985,6 @@ void DesktopLOKTest::testCommentsWriter()
} }
comphelper::LibreOfficeKit::setTiledAnnotations(true); comphelper::LibreOfficeKit::setTiledAnnotations(true);
comphelper::LibreOfficeKit::setActive(false);
} }
...@@ -2094,7 +2036,6 @@ void DesktopLOKTest::testCommentsCalc() ...@@ -2094,7 +2036,6 @@ void DesktopLOKTest::testCommentsCalc()
CPPUNIT_ASSERT_EQUAL(2, nIdx); CPPUNIT_ASSERT_EQUAL(2, nIdx);
comphelper::LibreOfficeKit::setTiledAnnotations(true); comphelper::LibreOfficeKit::setTiledAnnotations(true);
comphelper::LibreOfficeKit::setActive(false);
} }
...@@ -2152,7 +2093,6 @@ void DesktopLOKTest::testCommentsImpress() ...@@ -2152,7 +2093,6 @@ void DesktopLOKTest::testCommentsImpress()
CPPUNIT_ASSERT_EQUAL(2, nIdx); CPPUNIT_ASSERT_EQUAL(2, nIdx);
comphelper::LibreOfficeKit::setTiledAnnotations(true); comphelper::LibreOfficeKit::setTiledAnnotations(true);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testCommentsCallbacksWriter() void DesktopLOKTest::testCommentsCallbacksWriter()
...@@ -2239,8 +2179,6 @@ void DesktopLOKTest::testCommentsCallbacksWriter() ...@@ -2239,8 +2179,6 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
CPPUNIT_ASSERT(!aStream.str().empty()); CPPUNIT_ASSERT(!aStream.str().empty());
boost::property_tree::read_json(aStream, aTree); boost::property_tree::read_json(aStream, aTree);
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size());
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testRunMacro() void DesktopLOKTest::testRunMacro()
...@@ -2256,8 +2194,6 @@ void DesktopLOKTest::testRunMacro() ...@@ -2256,8 +2194,6 @@ void DesktopLOKTest::testRunMacro()
bNonExistentMacro = aOffice.m_pOfficeClass->runMacro(&aOffice, OString("macro:///I.Am.Not(There)").getStr()); bNonExistentMacro = aOffice.m_pOfficeClass->runMacro(&aOffice, OString("macro:///I.Am.Not(There)").getStr());
CPPUNIT_ASSERT(!bNonExistentMacro); CPPUNIT_ASSERT(!bNonExistentMacro);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testExtractParameter() void DesktopLOKTest::testExtractParameter()
...@@ -2288,8 +2224,6 @@ void DesktopLOKTest::testExtractParameter() ...@@ -2288,8 +2224,6 @@ void DesktopLOKTest::testExtractParameter()
aValue = extractParameter(aOptions, "Language"); aValue = extractParameter(aOptions, "Language");
CPPUNIT_ASSERT_EQUAL(OUString(), aValue); CPPUNIT_ASSERT_EQUAL(OUString(), aValue);
CPPUNIT_ASSERT_EQUAL(OUString("Something1,Something2=blah,Something3"), aOptions); CPPUNIT_ASSERT_EQUAL(OUString("Something1,Something2=blah,Something3"), aOptions);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::readFileIntoByteVector(OUString const & sFilename, std::vector<unsigned char> & rByteVector) void DesktopLOKTest::readFileIntoByteVector(OUString const & sFilename, std::vector<unsigned char> & rByteVector)
...@@ -2328,8 +2262,6 @@ void DesktopLOKTest::testGetSignatureState_Signed() ...@@ -2328,8 +2262,6 @@ void DesktopLOKTest::testGetSignatureState_Signed()
nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
CPPUNIT_ASSERT_EQUAL(int(1), nState); CPPUNIT_ASSERT_EQUAL(int(1), nState);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testGetSignatureState_NonSigned() void DesktopLOKTest::testGetSignatureState_NonSigned()
...@@ -2340,7 +2272,6 @@ void DesktopLOKTest::testGetSignatureState_NonSigned() ...@@ -2340,7 +2272,6 @@ void DesktopLOKTest::testGetSignatureState_NonSigned()
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
CPPUNIT_ASSERT_EQUAL(int(0), nState); CPPUNIT_ASSERT_EQUAL(int(0), nState);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testInsertCertificate_DER_ODT() void DesktopLOKTest::testInsertCertificate_DER_ODT()
...@@ -2393,8 +2324,6 @@ void DesktopLOKTest::testInsertCertificate_DER_ODT() ...@@ -2393,8 +2324,6 @@ void DesktopLOKTest::testInsertCertificate_DER_ODT()
int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
CPPUNIT_ASSERT_EQUAL(int(1), nState); CPPUNIT_ASSERT_EQUAL(int(1), nState);
comphelper::LibreOfficeKit::setActive(false);
} }
...@@ -2456,8 +2385,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_ODT() ...@@ -2456,8 +2385,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_ODT()
int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
CPPUNIT_ASSERT_EQUAL(int(1), nState); CPPUNIT_ASSERT_EQUAL(int(1), nState);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testInsertCertificate_PEM_DOCX() void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
...@@ -2518,8 +2445,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX() ...@@ -2518,8 +2445,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument); int nState = pDocument->m_pDocumentClass->getSignatureState(pDocument);
CPPUNIT_ASSERT_EQUAL(int(5), nState); CPPUNIT_ASSERT_EQUAL(int(5), nState);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testSignDocument_PEM_PDF() void DesktopLOKTest::testSignDocument_PEM_PDF()
...@@ -2578,8 +2503,6 @@ void DesktopLOKTest::testSignDocument_PEM_PDF() ...@@ -2578,8 +2503,6 @@ void DesktopLOKTest::testSignDocument_PEM_PDF()
aPrivateKey.data(), int(aPrivateKey.size())); aPrivateKey.data(), int(aPrivateKey.size()));
CPPUNIT_ASSERT(bResult); CPPUNIT_ASSERT(bResult);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testTextSelectionHandles() void DesktopLOKTest::testTextSelectionHandles()
...@@ -2621,8 +2544,6 @@ void DesktopLOKTest::testTextSelectionHandles() ...@@ -2621,8 +2544,6 @@ void DesktopLOKTest::testTextSelectionHandles()
free(pText); free(pText);
CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 275"), m_aTextSelectionStart); CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 275"), m_aTextSelectionStart);
CPPUNIT_ASSERT_EQUAL(OString("1898, 1418, 0, 275"), m_aTextSelectionEnd); CPPUNIT_ASSERT_EQUAL(OString("1898, 1418, 0, 275"), m_aTextSelectionEnd);
comphelper::LibreOfficeKit::setActive(false);
} }
void DesktopLOKTest::testDialogPaste() void DesktopLOKTest::testDialogPaste()
...@@ -2650,7 +2571,6 @@ void DesktopLOKTest::testDialogPaste() ...@@ -2650,7 +2571,6 @@ void DesktopLOKTest::testDialogPaste()
static_cast<SystemWindow*>(pWindow.get())->Close(); static_cast<SystemWindow*>(pWindow.get())->Close();
Scheduler::ProcessEventsToIdle(); Scheduler::ProcessEventsToIdle();
comphelper::LibreOfficeKit::setActive(false);
} }
namespace { namespace {
......
...@@ -87,6 +87,7 @@ ...@@ -87,6 +87,7 @@
#include <com/sun/star/linguistic2/LinguServiceManager.hpp> #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
#include <com/sun/star/linguistic2/XSpellChecker.hpp> #include <com/sun/star/linguistic2/XSpellChecker.hpp>
#include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/lang/DisposedException.hpp>
#include <editeng/fontitem.hxx> #include <editeng/fontitem.hxx>
#include <editeng/flstitem.hxx> #include <editeng/flstitem.hxx>
...@@ -916,7 +917,14 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone ...@@ -916,7 +917,14 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
LibLODocument_Impl::~LibLODocument_Impl() LibLODocument_Impl::~LibLODocument_Impl()
{ {
try
{
mxComponent->dispose(); mxComponent->dispose();
}
catch (const css::lang::DisposedException& rException)
{
SAL_WARN("lok", "failed to dispose document:" << rException.Message);
}
} }
CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData) CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, LibreOfficeKitCallback pCallback, void* pData)
......
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