/* -*- 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/.
*/
/// Test opening a dialog in sd class SdDialogsTest : public ScreenshotTest
{ private: /// Document and ComponentContext
uno::Reference<lang::XComponent> mxComponent;
/// initially created SdAbstractDialogFactory and pointer to document
SdAbstractDialogFactory* mpFact;
SdXImpressDocument* mpImpressDocument;
/// on-demand created instances required for various dialogs to open
::sd::DrawDocShell* mpDocShell;
::sd::ViewShell* mpViewShell;
::sd::DrawView* mpDrawView;
/// helper method to populate KnownDialogs, called in setUp(). Needs to be /// written and has to add entries to KnownDialogs virtualvoid registerKnownDialogsByID(mapType& rKnownDialogs) override;
/// dialog creation for known dialogs by ID. Has to be implemented for /// each registered known dialog virtual VclPtr<VclAbstractDialog> createDialogByID(sal_uInt32 nID) override;
const SfxItemSet& SdDialogsTest::getEmptySfxItemSet()
{ if (!mpEmptySfxItemSet)
{ // needs an SfxItemSet, use the one from the 1st object
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
mpEmptySfxItemSet.reset( new SfxItemSet(pDrawDoc->GetItemPool()) );
CPPUNIT_ASSERT(mpEmptySfxItemSet);
}
if (getSdAbstractDialogFactory())
{ switch (nID)
{ case 0:
{ // CreateBreakDlg(weld::Window* pWindow, ::sd::DrawView* pDrView, ::sd::DrawDocShell* pShell, sal_uLong nSumActionCount, sal_uLong nObjCount) override; // this dialog requires pDrawView. It does not show much when // there is no object selected that can be broken up. For better // results it might be necessary to add/select an object that // delivers a good metafile (which is the base for breaking)
pRetval = getSdAbstractDialogFactory()->CreateBreakDlg(
Application::GetDefDialogParent(),
getDrawView(),
getDocShell(),
0,
0); break;
} case 1:
{ // needs an SfxItemSet, use the one from the 1st object
pRetval = getSdAbstractDialogFactory()->CreateCopyDlg(
getViewShell()->GetFrameWeld(),
getSfxItemSetFromSdrObject(),
getDrawView()); break;
} case 2:
{ // CreateSdCustomShowDlg(SdDrawDocument& rDrawDoc) = 0;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
//SdOptions* pOptions = SdModule::get()->GetSdOptions(DocumentType::Impress);
aDlgSet.Put(SfxInt32Item(ATTR_PRESENT_DISPLAY, 0 /*pOptions->GetDisplay()*/));
pRetval = getSdAbstractDialogFactory()->CreateSdStartPresentationDlg(
Application::GetDefDialogParent(),
aDlgSet,
std::vector<OUString>(),
nullptr); break;
} case 13:
{ // CreateRemoteDialog(vcl::Window* pWindow) override; // ad for RemoteDialog
pRetval = getSdAbstractDialogFactory()->CreateRemoteDialog(
Application::GetDefDialogParent()); break;
} case 14:
{ // CreateSdPresLayoutTemplateDlg(SfxObjectShell* pDocSh, weld::Window* pParent, const SdResId& DlgId, SfxStyleSheetBase& rStyleBase, PresentationObjects ePO, SfxStyleSheetBasePool* pSSPool) override; // use STR_PSEUDOSHEET_TITLE configuration, see futempl.cxx for more possible configurations // may be nicer on the long run to take a configuration which represents a selected SdrObject
SfxStyleSheetBasePool* pStyleSheetPool = getDocShell()->GetStyleSheetPool();
CPPUNIT_ASSERT(pStyleSheetPool);
SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->First(SfxStyleFamily::Page);
CPPUNIT_ASSERT(pStyleSheet);
pRetval = getSdAbstractDialogFactory()->CreateSdPresLayoutTemplateDlg(
getDocShell(),
Application::GetDefDialogParent(), false,
*pStyleSheet,
PresentationObjects::Title,
pStyleSheetPool); break;
} case 15:
{ // CreateSdPresLayoutDlg(::sd::DrawDocShell* pDocShell, vcl::Window* pWindow, const SfxItemSet& rInAttrs) override;
pRetval = getSdAbstractDialogFactory()->CreateSdPresLayoutDlg(
Application::GetDefDialogParent(),
getDocShell(),
getEmptySfxItemSet()); break;
} case 16:
{ // CreateSdTabTemplateDlg(const SfxObjectShell* pDocShell, SfxStyleSheetBase& rStyleBase, SdrModel* pModel, SdrView* pView) override; // pretty similar to CreateSdPresLayoutTemplateDlg, see above // may be nicer on the long run to take a configuration which represents a selected SdrObject
SfxStyleSheetBasePool* pStyleSheetPool = getDocShell()->GetStyleSheetPool();
CPPUNIT_ASSERT(pStyleSheetPool);
SfxStyleSheetBase* pStyleSheet = pStyleSheetPool->First(SfxStyleFamily::Pseudo);
CPPUNIT_ASSERT(pStyleSheet);
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
pRetval = getSdAbstractDialogFactory()->CreateSdTabTemplateDlg(
getViewShell()->GetFrameWeld(),
getDocShell(),
*pStyleSheet,
pDrawDoc,
getDrawView()); break;
} case 17:
{ // CreatSdActionDialog(const SfxItemSet& rAttr, ::sd::View* pView) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
SfxItemSet aSet(pDrawDoc->GetItemPool(), svl::Items<ATTR_ANIMATION_START, ATTR_ACTION_END>);
aSet.Put(SfxBoolItem(ATTR_ANIMATION_ACTIVE, false));
aSet.Put(SfxUInt16Item(ATTR_ANIMATION_EFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
aSet.Put(SfxUInt16Item(ATTR_ANIMATION_TEXTEFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
aSet.InvalidateItem(ATTR_ANIMATION_SPEED);
aSet.Put(SfxBoolItem(ATTR_ANIMATION_FADEOUT, false));
aSet.Put(SvxColorItem(COL_LIGHTGRAY, ATTR_ANIMATION_COLOR));
aSet.Put(SfxBoolItem(ATTR_ANIMATION_INVISIBLE, false));
aSet.Put(SfxBoolItem(ATTR_ANIMATION_SOUNDON, false));
aSet.InvalidateItem(ATTR_ANIMATION_SOUNDFILE);
aSet.Put(SfxBoolItem(ATTR_ANIMATION_PLAYFULL, false));
aSet.Put(SfxUInt16Item(ATTR_ACTION, sal_uInt16(presentation::ClickAction_NONE)));
aSet.InvalidateItem(ATTR_ACTION_FILENAME);
aSet.Put(SfxUInt16Item(ATTR_ACTION_EFFECT, sal_uInt16(presentation::AnimationEffect_NONE)));
aSet.InvalidateItem(ATTR_ACTION_EFFECTSPEED);
aSet.Put(SfxBoolItem(ATTR_ACTION_SOUNDON, false));
aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false));
pRetval = getSdAbstractDialogFactory()->CreatSdActionDialog(
getViewShell()->GetFrameWeld(),
aSet,
getDrawView()); break;
} case 18:
{ // CreateSdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd::DrawDocShell* pDocShell) override; // works well with empty Bitmap, but my be nicer with setting one
Bitmap aEmptyBitmap;
pRetval = getSdAbstractDialogFactory()->CreateSdVectorizeDlg(
Application::GetDefDialogParent(),
aEmptyBitmap,
getDocShell()); break;
} case 19:
{ // CreateSdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pDoc) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
pRetval = getSdAbstractDialogFactory()->CreateSdPhotoAlbumDialog(
Application::GetDefDialogParent(),
pDrawDoc); break;
} case 20:
{ // CreateMasterLayoutDialog(weld::Window* pParent, SdDrawDocument* pDoc, SdPage*) override;
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
CPPUNIT_ASSERT(pSdPage);
pRetval = getSdAbstractDialogFactory()->CreateMasterLayoutDialog(
Application::GetDefDialogParent(),
pDrawDoc,
pSdPage); break;
} case 21:
{ // CreateHeaderFooterDialog(sd::ViewShell* pViewShell, weld::Window* pParent, SdDrawDocument* pDoc, SdPage* pCurrentPage) override; // This is a hard case, for two reasons: // - It uses BaseClass TabPage which has a very sparse interface, // need to add 'Screenshot interface' there and implement // - The concrete dialog has two TabPages which use the *same* // .ui file, so extended markup will be needed to differ these two // cases
SdDrawDocument* pDrawDoc = getSdXImpressDocument()->GetDoc();
CPPUNIT_ASSERT(pDrawDoc);
SdPage* pSdPage = pDrawDoc->GetSdPage(0, PageKind::Standard);
CPPUNIT_ASSERT(pSdPage);
pRetval = getSdAbstractDialogFactory()->CreateHeaderFooterDialog(
*getViewShell(),
Application::GetDefDialogParent(),
pDrawDoc,
pSdPage); break;
} default: break;
}
}
return pRetval;
}
void SdDialogsTest::openAnyDialog()
{ /// example how to process an input file containing the UXMLDescriptions of the dialogs /// to dump if (true)
{
processDialogBatchFile(u"sd/qa/unit/data/dialogs-test.txt");
}
/// example how to dump all known dialogs if ((false))
{
processAllKnownDialogs();
}
/// example how to dump exactly one known dialog if ((false))
{ // example for SfxTabDialog: 5 -> "modules/sdraw/ui/drawpagedialog.ui" // example for TabDialog: 22 -> "modules/simpress/ui/headerfooterdialog.ui"
ScopedVclPtr<VclAbstractDialog> pDlg(createDialogByID(5));
if (pDlg)
{ // known dialog, dump screenshot to path
dumpDialogToPath(*pDlg);
} else
{ // unknown dialog, should not happen in this basic loop. // You have probably forgotten to add a case and // implementation to createDialogByID, please do this
}
}
/// example how to dump a dialog using fallback functionality if ((false))
{ // unknown dialog, try fallback to generic created // VclBuilder-generated instance. Keep in mind that Dialogs // using this mechanism will probably not be layouted well // since the setup/initialization part is missing. Thus, // only use for fallback when only the UI file is available. // // Take any example here, it's only for demonstration - using // even a known one to demonstrate the fallback possibility
dumpDialogToPath("modules/sdraw/ui/breakdialog.ui");
}
}
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.