/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * 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/.
*/
if (bUseEscape)
{
typeKey(pImpressDocument, KEY_ESCAPE);
CPPUNIT_ASSERT(!pView->IsTextEdit());
}
}
sd::slidesorter::SlideSorterViewShell* SdUiImpressTest::getSlideSorterViewShell()
{ auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
sd::slidesorter::SlideSorterViewShell* pSSVS = nullptr; // Same as in sd/qa/unit/misc-tests.cxx for (int i = 0; i < 1000; i++)
{ // Process all Tasks - slide sorter is created here
Scheduler::ProcessEventsToIdle(); if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(
pViewShell->GetViewShellBase()))
!= nullptr) break;
osl::Thread::wait(std::chrono::milliseconds(100));
}
CPPUNIT_ASSERT(pSSVS); return pSSVS;
}
// Move the shape in window 2 & undo.
SdPage* pPage2 = pViewShell2->GetActualPage();
CPPUNIT_ASSERT(pPage1 != pPage2);
SdrObject* pShape2 = pPage2->GetObj(0);
SdrView* pView2 = pViewShell2->GetView();
pView2->MarkObj(pShape2, pView2->GetSdrPageView());
pView2->MoveMarkedObj(Size(1, 1), /*bCopy=*/false); // Without the accompanying fix in place, this test would have failed with an assertion failure // in SdrObjEditView::SdrEndTextEdit() as mpOldTextEditUndoManager was not nullptr.
pViewShell2->GetViewFrame()->GetDispatcher()->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
// Rotate the shape in window 2 & undo.
pView2->MarkObj(pShape2, pView2->GetSdrPageView());
pView2->RotateMarkedObj(pShape2->GetLastBoundRect().Center(), /*nAngle=*/45_deg100); // Without the accompanying fix in place, this test would have failed with an assertion failure // in SdrObjEditView::SdrEndTextEdit() as mpOldTextEditUndoManager was not nullptr.
pViewShell2->GetViewFrame()->GetDispatcher()->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
// Start text edit in window 2. // tdf#125824
pView2->MarkObj(pShape2, pView2->GetSdrPageView());
pView2->SdrBeginTextEdit(pShape2);
CPPUNIT_ASSERT(pView2->IsTextEdit()); // Write 'test' inside the shape
SfxStringItem aInputString(SID_ATTR_CHAR, u"test"_ustr);
pViewShell2->GetViewFrame()->GetDispatcher()->ExecuteList(SID_ATTR_CHAR, SfxCallMode::SYNCHRON,
{ &aInputString });
CPPUNIT_ASSERT(pView2->GetTextEditObject());
EditView& rEditView = pView2->GetTextEditOutlinerView()->GetEditView();
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), rEditView.GetSelection().start.nIndex);
pView2->SdrEndTextEdit(); // Without the accompanying fix in place, this test would have failed with an assertion failure // in SdrObjEditView::SdrEndTextEdit() as mpOldTextEditUndoManager was not nullptr.
pViewShell2->GetViewFrame()->GetDispatcher()->Execute(SID_UNDO, SfxCallMode::SYNCHRON);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf126197)
{ // Load the document and create two new windows.
createSdImpressDoc("tdf126197.odp"); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_NEWWINDOW, SfxCallMode::SYNCHRON);
sd::ViewShell* pViewShell1 = pImpressDocument->GetDocShell()->GetViewShell();
pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_NEWWINDOW, SfxCallMode::SYNCHRON);
sd::ViewShell* pViewShell2 = pImpressDocument->GetDocShell()->GetViewShell();
CPPUNIT_ASSERT(pViewShell1 != pViewShell2);
// Without the accompanying fix in place, this test would have failed with an assertion failure // in SdrObjEditView::SdrEndTextEdit()
pViewShell2->GetViewFrame()->GetDispatcher()->Execute(SID_DELETE, SfxCallMode::SYNCHRON);
}
// split the (auto-selected) svg
dispatchCommand(mxComponent, u".uno:Break"_ustr, {});
SdrObject* pObject = pActualPage->GetObj(2); const XLineStyleItem& rStyleItem = pObject->GetMergedItem(XATTR_LINESTYLE); // tdf#115162: Without the fix in place, this test would have failed with // - Expected: 2 (LineStyle_DASH) // - Actual : 1 (LineStyle_SOLID)
CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH, rStyleItem.GetValue());
}
// Get the newly created shape that has the text '100' in it
uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(4, 0));
uno::Reference<text::XTextRange> xParagraph1(getParagraphFromShape(0, xShape));
uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph1));
CPPUNIT_ASSERT_EQUAL(u"100"_ustr, xRun->getString());
/* before this fix the font sizes were way too small - Expected: 7.5
- Actual : 0.300000011920929 */
CPPUNIT_ASSERT_DOUBLES_EQUAL(7.5, fFontSize1, 0.01);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf96206)
{ // Copying/pasting slide referring to a non-default master with a text duplicated the master
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testDocumentCut)
{ // Test cutting slides and verifying the document state afterwards
createSdImpressDoc("odp/tdf96206.odp");
// Get the slide sorter and controller
sd::slidesorter::SlideSorterViewShell* pSSVS = getSlideSorterViewShell(); auto& rSSController = pSSVS->GetSlideSorter().GetController();
// Get document and initial page count
SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
// Select all slides
rSSController.GetPageSelector().SelectAllPages();
// Check that slides are selected
CPPUNIT_ASSERT(rSSController.GetPageSelector().GetSelectedPageCount() > 0);
// Cut the selected slides
rSSController.GetClipboard().DoCut();
// Paste the cut slides
rSSController.GetClipboard().DoPaste();
// After pasting, we should have at least the initial number of pages const sal_uInt16 nPageCountAfterPaste = pDoc->GetSdPageCount(PageKind::Standard);
CPPUNIT_ASSERT(nPageCountAfterPaste >= nInitialPageCount);
// Verify that master page count remains unchanged throughout the operation const sal_uInt16 nMasterPageCount = pDoc->GetMasterSdPageCount(PageKind::Standard);
CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), nMasterPageCount);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf45617_leading_underscore_master_name)
{ // Test master page name with underscore at first position
createSdImpressDoc("odp/tdf96708.odp");
SdPage* pMasterPage = pDoc->GetMasterSdPage(0, PageKind::Standard); // Rename the master page with leading underscore
pDoc->RenameLayoutTemplate(pMasterPage->GetLayoutName(), "_Master0");
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf45617_middle_underscore_master_name)
{ // Test master page name with underscore in the middle
createSdImpressDoc("odp/tdf96708.odp");
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf45617_trailing_underscore_master_name)
{ // Test master page name with underscore at the end
createSdImpressDoc("odp/tdf96708.odp");
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf45617_space_in_master_name)
{ // Test master page name with space in the middle
createSdImpressDoc("odp/tdf96708.odp");
SdPage* pMasterPage = pDoc->GetMasterSdPage(0, PageKind::Standard); // Rename the master page with space in the middle
pDoc->RenameLayoutTemplate(pMasterPage->GetLayoutName(), "Master 0");
// Copy and paste master page only
rSSController.GetClipboard().DoCopy(true);
rSSController.GetClipboard().DoPaste(true);
// Check that a master page was added const sal_uInt16 nAfterPasteMasterPageCount = pDoc->GetMasterSdPageCount(PageKind::Standard);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(nInitialMasterPageCount + 1),
nAfterPasteMasterPageCount);
// Undo the master page merge
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {});
// Check that the master page count is back to the initial value const sal_uInt16 nAfterUndoMasterPageCount = pDoc->GetMasterSdPageCount(PageKind::Standard);
CPPUNIT_ASSERT_EQUAL(nInitialMasterPageCount, nAfterUndoMasterPageCount);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf128651)
{ // Error was, that undo and redo changes size of the shape. Affected actions were e.g. // extrusion on/off, shadow on/off, changes on line or fill attributes. // All these actions do not change the snap rectangle.
createSdImpressDoc("tdf128651_CustomShapeUndo.odp"); auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
SdPage* pActualPage = pViewShell->GetActualPage();
SdrObject* pObject = pActualPage->GetObj(0); auto pCustomShape = dynamic_cast<SdrObjCustomShape*>(pObject);
CPPUNIT_ASSERT_MESSAGE("No Shape", pCustomShape); const sal_Int32 nOrigWidth(pCustomShape->GetSnapRect().GetWidth());
uno::Reference<text::XText> xText
= uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
// Get first paragraph
uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
// Hide slide and check the number of available undo actions
dispatchCommand(mxComponent, u".uno:ShowSlide"_ustr, {});
dispatchCommand(mxComponent, u".uno:HideSlide"_ustr, {});
// There should be a single undo action, i.e., hide slide auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
SdDrawDocument* pDocument = pXImpressDocument->GetDoc();
sd::UndoManager* pUndoManager = pDocument->GetUndoManager(); // Check if there is the correct undo action, i.e., hide slide
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
CPPUNIT_ASSERT_EQUAL(SdResId(STR_UNDO_HIDE_SLIDE), pUndoManager->GetUndoActionComment());
sd::slidesorter::SlideSorterViewShell* pSSVS = getSlideSorterViewShell();
// Check if the page is actually hidden auto& rSSController = pSSVS->GetSlideSorter().GetController(); auto& rPageSelector = rSSController.GetPageSelector();
CPPUNIT_ASSERT_EQUAL(true, rPageSelector.IsPageExcluded(0));
// Undo hide slide action and check the number of available redo actions // including the correct undo action, i.e., hide slide
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {});
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetRedoActionCount());
CPPUNIT_ASSERT_EQUAL(SdResId(STR_UNDO_HIDE_SLIDE), pUndoManager->GetRedoActionComment());
CPPUNIT_ASSERT_EQUAL(false, rPageSelector.IsPageExcluded(0));
// Show slide and check the number of available undo actions
dispatchCommand(mxComponent, u".uno:Redo"_ustr, {});
CPPUNIT_ASSERT_EQUAL(true, rPageSelector.IsPageExcluded(0));
dispatchCommand(mxComponent, u".uno:ShowSlide"_ustr, {}); // There should be two undo actions, i.e., show and hide slide
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pUndoManager->GetUndoActionCount());
CPPUNIT_ASSERT_EQUAL(SdResId(STR_UNDO_SHOW_SLIDE), pUndoManager->GetUndoActionComment());
CPPUNIT_ASSERT_EQUAL(false, rPageSelector.IsPageExcluded(0));
// Undo show slide and check the number of available undo/redo actions
dispatchCommand(mxComponent, u".uno:Undo"_ustr, {}); // There should be one undo action, i.e., hide slide, and one redo action, i.e., show slide
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetUndoActionCount());
CPPUNIT_ASSERT_EQUAL(SdResId(STR_UNDO_HIDE_SLIDE), pUndoManager->GetUndoActionComment());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pUndoManager->GetRedoActionCount());
CPPUNIT_ASSERT_EQUAL(SdResId(STR_UNDO_SHOW_SLIDE), pUndoManager->GetRedoActionComment());
CPPUNIT_ASSERT_EQUAL(true, rPageSelector.IsPageExcluded(0));
}
// Move slide 'Test 2' up for (size_t i = 2; i > 0; --i)
{
dispatchCommand(mxComponent, u".uno:MovePageUp"_ustr, {});
checkCurrentPageNumber(i);
CPPUNIT_ASSERT_EQUAL(u"Test 2"_ustr, pViewShell->GetActualPage()->GetName());
}
// Move slide 'Test 2' down for (size_t i = 2; i < 4; ++i)
{
dispatchCommand(mxComponent, u".uno:MovePageDown"_ustr, {});
checkCurrentPageNumber(i);
CPPUNIT_ASSERT_EQUAL(u"Test 2"_ustr, pViewShell->GetActualPage()->GetName());
}
// Move slide 'Test 2' to the top
dispatchCommand(mxComponent, u".uno:MovePageFirst"_ustr, {});
checkCurrentPageNumber(1);
CPPUNIT_ASSERT_EQUAL(u"Test 2"_ustr, pViewShell->GetActualPage()->GetName());
// Move slide 'Test 2' to the bottom
dispatchCommand(mxComponent, u".uno:MovePageLast"_ustr, {});
checkCurrentPageNumber(3);
CPPUNIT_ASSERT_EQUAL(u"Test 2"_ustr, pViewShell->GetActualPage()->GetName());
}
// Move to A1 using Alt + Tab and write 'A' for (int i = 0; i < 3; i++)
{
pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_SHIFT | KEY_TAB);
pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_SHIFT | KEY_TAB);
Scheduler::ProcessEventsToIdle();
}
typeString(pXImpressDocument, u"A");
// Move to A2 with Tab and write 'B'
typeKey(pXImpressDocument, KEY_TAB);
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillColor)
{ // Load the document and create two new windows.
createSdImpressDoc("tdf126197.odp"); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
Color aColor = rPageAttr.GetItem(XATTR_FILLCOLOR)->GetColorValue();
CPPUNIT_ASSERT_EQUAL(COL_LIGHTRED, aColor);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testPageFillGradient)
{ // Load the document and create two new windows.
createSdImpressDoc("tdf126197.odp"); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf134053)
{ // Error was, that dashes and dots were longer than in MS Office.
createSdImpressDoc("pptx/tdf134053_dashdot.pptx"); auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
SdPage* pActualPage = pViewShell->GetActualPage();
SdrObject* pShape = pActualPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("No Shape", pShape);
// tdf#114613: Without the fix in place, this test would have failed with // - Expected: 0 // - Actual : 8
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pUndoManager->GetUndoActionCount());
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pUndoManager->GetRedoActionCount());
// Because 0% is not possible as dash length (as of June 2020) 1% is used in the fix.
CPPUNIT_ASSERT_EQUAL_MESSAGE("Distance", 399.0, dash.GetDistance());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot length", 301.0, dash.GetDotLen());
CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash length", 1.0, dash.GetDashLen());
}
// set the same state as now and we don't expect any change (no-toggle)
params = comphelper::InitPropertySequence({ { "Enable", uno::Any(!bSet) } });
dispatchCommand(mxComponent, u".uno:SpellOnline"_ustr, params);
CPPUNIT_ASSERT_EQUAL(!bSet, pImpressDocument->GetDoc()->GetOnlineSpell());
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf38669)
{
createSdImpressDoc(); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pImpressDocument);
uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(2), uno::UNO_QUERY); // Without the fix in place, this test would have failed with: // - Expected: ° // - Actual : ㅀ
CPPUNIT_ASSERT_EQUAL(u"°"_ustr, xShape->getString());
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf151417)
{
createSdImpressDoc(); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pImpressDocument);
for (int i = 0; i < 3; i++)
{
uno::Reference<beans::XPropertySet> XPropSet(xDrawPage->getByIndex(i), uno::UNO_QUERY);
drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
XPropSet->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle;
// Without the fix in place, this test would have failed with // with drawing::FillStyle_NONE != drawing::FillStyle_SOLID
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, eFillStyle);
}
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testSearchAllInDocumentAndNotes)
{ // tdf#142478 // "find all" produces a crash when the search string exists in notes // and the document
createSdImpressDoc("odp/search-all-notes.odp");
auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
CPPUNIT_ASSERT(pViewShell);
#if !defined(_WIN32) && !defined(MACOSX) // for some reason, the search for "second" (or "Second") didn't return page 2 in WIN and MACOS
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf123658_SearchAfterSlideChange)
{
createSdImpressDoc("odp/tdf123658_SearchAfterSlideChange.odp");
auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
pXImpressDocument->setPart(0); // Switch to 1st page
lcl_search(u"of"_ustr); // Instead of finding this on the 1st page (or on the 2nd page would be acceptable too) // it was going to the third page.
checkCurrentPageNumber(1);
} #endif
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme)
{ // Given an Impress document with a shape, with its text selected:
createSdImpressDoc();
uno::Reference<drawing::XDrawPagesSupplier> xPagesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xPage(xPagesSupplier->getDrawPages()->getByIndex(0),
uno::UNO_QUERY);
uno::Reference<text::XTextRange> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
{
uno::Reference<text::XSimpleText> xText = xShape->getText();
xText->insertString(xText->getStart(), u"test"_ustr, false);
}
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<view::XSelectionSupplier> xController(xModel->getCurrentController(),
uno::UNO_QUERY);
xController->select(uno::Any(xShape));
Scheduler::ProcessEventsToIdle();
dispatchCommand(mxComponent, u".uno:Text"_ustr, {}); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
SdrView* pView = pViewShell->GetView();
CPPUNIT_ASSERT(pView->IsTextEdit());
dispatchCommand(mxComponent, u".uno:SelectAll"_ustr, {});
// When picking a theme color on the sidebar:
{
model::ComplexColor aComplexColor;
aComplexColor.setThemeColor(model::ThemeColorType::Accent1);
aComplexColor.addTransformation({ model::TransformationType::LumMod, 2000 });
aComplexColor.addTransformation({ model::TransformationType::LumOff, 8000 });
// When setting the fill color of that shape, with theme metadata & effects:
uno::Sequence<beans::PropertyValue> aColorArgs = {
comphelper::makePropertyValue(u"Color.Color"_ustr,
sal_Int32(0xdae3f3)), // 80% light blue
comphelper::makePropertyValue(u"Color.ComplexColorJSON"_ustr, uno::Any(aJSON)),
};
dispatchCommand(mxComponent, u".uno:Color"_ustr, aColorArgs);
}
// Then make sure the theme "metadata" is set in the document model:
pView->EndTextEditCurrentView();
CPPUNIT_ASSERT(!pView->IsTextEdit());
uno::Reference<container::XEnumerationAccess> xShapeParaAccess(xShape, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xPara(
xShapeParaAccess->createEnumeration()->nextElement(), uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xPortion(xPara->createEnumeration()->nextElement(),
uno::UNO_QUERY);
{
uno::Reference<util::XComplexColor> xComplexColor;
CPPUNIT_ASSERT(xPortion->getPropertyValue(u"CharComplexColor"_ustr) >>= xComplexColor);
CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
aComplexColor.getTransformations()[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(2000), aComplexColor.getTransformations()[0].mnValue);
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
aComplexColor.getTransformations()[1].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(8000), aComplexColor.getTransformations()[1].mnValue);
}
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorTheme)
{ // Given an Impress document with a selected shape:
createSdImpressDoc();
uno::Reference<drawing::XDrawPagesSupplier> xPagesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<drawing::XDrawPage> xPage(xPagesSupplier->getDrawPages()->getByIndex(0),
uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<view::XSelectionSupplier> xController(xModel->getCurrentController(),
uno::UNO_QUERY);
xController->select(uno::Any(xShape));
// Change fill color
{
model::ComplexColor aComplexColor;
aComplexColor.setThemeColor(model::ThemeColorType::Accent1);
aComplexColor.addTransformation({ model::TransformationType::LumMod, 4000 });
aComplexColor.addTransformation({ model::TransformationType::LumOff, 6000 });
// When setting the fill color of that shape, with theme metadata & effects:
uno::Sequence<beans::PropertyValue> aColorArgs = {
comphelper::makePropertyValue(u"FillColor.Color"_ustr, sal_Int32(0xed7d31)), // orange
comphelper::makePropertyValue(u"FillColor.ComplexColorJSON"_ustr,
uno::Any(aJSON)), // accent 1
};
dispatchCommand(mxComponent, u".uno:FillColor"_ustr, aColorArgs);
}
// Then make sure the theme index is not lost when the sidebar sets it:
{
uno::Reference<util::XComplexColor> xComplexColor;
CPPUNIT_ASSERT(xShape->getPropertyValue(u"FillComplexColor"_ustr) >>= xComplexColor);
CPPUNIT_ASSERT(xComplexColor.is()); auto aComplexColor = model::color::getFromXComplexColor(xComplexColor);
CPPUNIT_ASSERT_EQUAL(model::ThemeColorType::Accent1, aComplexColor.getThemeColorType());
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumMod,
aComplexColor.getTransformations()[0].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), aComplexColor.getTransformations()[0].mnValue);
CPPUNIT_ASSERT_EQUAL(model::TransformationType::LumOff,
aComplexColor.getTransformations()[1].meType);
CPPUNIT_ASSERT_EQUAL(sal_Int16(6000), aComplexColor.getTransformations()[1].mnValue);
}
}
// Without the fix in place, this test would have failed with // - Expected: 1 // - Actual : 0
CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_SOLID), static_cast<int>(eFillStyle));
CPPUNIT_ASSERT(xShape->getPropertyValue(u"FillColor"_ustr) >>= aColor);
CPPUNIT_ASSERT_EQUAL(COL_RED, aColor);
}
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testFillColorNoColor)
{ // Given an empty Impress document:
createSdImpressDoc(); auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell();
SfxDispatcher* pDispatcher = pViewShell->GetViewFrame()->GetDispatcher();
// When dispatching a fill color that only has a fill style (no color), then make sure we don't // crash:
XFillStyleItem aXFillStyleItem(drawing::FillStyle_NONE);
pDispatcher->ExecuteList(SID_ATTR_FILL_COLOR, SfxCallMode::RECORD, { &aXFillStyleItem });
}
uno::Reference<text::XText> xText
= uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
// TODO - Readd when we implement style level fill color and set that for default style /*CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testThemeShapeInsert) { // Given a document with a theme, accent1 color is set to 0x000004: createSdImpressDoc(); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<drawing::XMasterPageTarget> xMasterPageTarget(xDrawPage, uno::UNO_QUERY); uno::Reference<beans::XPropertySet> xMasterPage(xMasterPageTarget->getMasterPage(), uno::UNO_QUERY);
// When inserting a shape: uno::Sequence<beans::PropertyValue> aArgs = { comphelper::makePropertyValue("CreateDirectly", true), }; dispatchCommand(mxComponent, ".uno:BasicShapes.round-rectangle", aArgs);
// Then make sure the that fill color of the last shape is the accent1 color: sal_Int32 nShapeIndex = xDrawPage->getCount() - 1; uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(nShapeIndex), uno::UNO_QUERY); sal_Int32 nFillColor{}; xShape->getPropertyValue("FillColor") >>= nFillColor; // Without the accompanying fix in place, this test would have failed with: // - Expected: 0 / 0x000004 (~black) // - Actual : 7512015 / 0x729fcf (~blue) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x4), nFillColor);
}*/
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf166647_userpaint)
{ // The document contains two shapes on layer DrawnInSlideshow and is empty besides that. The // running slideshow is displayed in window mode, otherwise its additional window would be // suppressed by the test environment.
createSdImpressDoc("odp/tdf166647_userpaint.odp"); auto pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pXImpressDocument);
// Go in slideshow mode and back to edit mode
dispatchCommand(mxComponent, u".uno:Presentation"_ustr, {});
typeKey(pXImpressDocument, KEY_ESCAPE);
// Count shapes. Error was, that the shapes were duplicated and thus count was 4.
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
CPPUNIT_ASSERT(pViewShell);
CPPUNIT_ASSERT_EQUAL(size_t(2), pViewShell->GetActualPage()->GetObjCount());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.