From 3ca7be09834a26fbd1c371deabd7a58111092676 Mon Sep 17 00:00:00 2001 From: Armin Le Grand Date: Thu, 10 May 2018 17:49:19 +0200 Subject: Replace SVGFilter using SVGIO Target of this change is to get rid of the SVGFilter in current LO which is based on the standard-ODF importer using it's functionality by passing in/handing over temporary created XML-Stream-Data. First step is to alternatively import the given SVG file to a newly created Document and to strip the existing Filter-Code. Adding the first prototype of the changed import. It is capable of importing the given SVG to the created Draw/Impress document. It adds the SVG which gets imported by SVGIO as GraphicObject. It adapts sizes and positions of Page and GraphicObject to have a smooth import. Adding stripping of SVGFilter and used ressources. Done as deep as possible, hopefully all places found. Adapted now to create an Impress document. Also added needed adaptions to PageSize(s), including layout and PresObj stuff to make all MasterPages/LayoutPages work correctly. Added reaction on empty SVG. This is needed since the PageSize is adapted to the Graphic. With empty Graphic a Size(0,0) results and this goes wrong. Change-Id: Ia364a5783bee7dadcbe91e700efbabc121cf98f9 Reviewed-on: https://gerrit.libreoffice.org/54096 Tested-by: Jenkins Reviewed-by: Armin Le Grand --- sd/source/ui/view/viewshe2.cxx | 167 ++++++++++++----------------------------- 1 file changed, 46 insertions(+), 121 deletions(-) (limited to 'sd/source/ui') diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index f20469071b72..6c1ad846131c 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -470,139 +470,65 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, Orientation eOrientation, sal_uInt16 nPaperBin, bool bBackgroundFullSize) { - SdPage* pPage = nullptr; - SdUndoGroup* pUndoGroup = nullptr; - pUndoGroup = new SdUndoGroup(GetDoc()); - OUString aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT)); - pUndoGroup->SetComment(aString); - SfxViewShell* pViewShell = GetViewShell(); - OSL_ASSERT (pViewShell!=nullptr); - - sal_uInt16 i, nPageCnt = GetDoc()->GetMasterSdPageCount(ePageKind); - - Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START)); + const sal_uInt16 nMasterPageCnt(GetDoc()->GetMasterSdPageCount(ePageKind)); + const sal_uInt16 nPageCnt(GetDoc()->GetSdPageCount(ePageKind)); - for (i = 0; i < nPageCnt; i++) + if(0 == nPageCnt && 0 == nMasterPageCnt) { - // first, handle all master pages - pPage = GetDoc()->GetMasterSdPage(i, ePageKind); - - SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage, - pPage->GetSize(), - pPage->GetLeftBorder(), pPage->GetRightBorder(), - pPage->GetUpperBorder(), pPage->GetLowerBorder(), - pPage->GetOrientation(), - pPage->GetPaperBin(), - pPage->IsBackgroundFullSize(), - rNewSize, - nLeft, nRight, - nUpper, nLower, - bScaleAll, - eOrientation, - nPaperBin, - bBackgroundFullSize); - pUndoGroup->AddAction(pUndo); - - if (rNewSize.Width() > 0 || - nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0) - { - ::tools::Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower); - pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll); - - if (rNewSize.Width() > 0) - pPage->SetSize(rNewSize); - } - - if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 ) - { - pPage->SetBorder(nLeft, nUpper, nRight, nLower); - } - - pPage->SetOrientation(eOrientation); - pPage->SetPaperBin( nPaperBin ); - pPage->SetBackgroundFullSize( bBackgroundFullSize ); - - if ( ePageKind == PageKind::Standard ) - GetDoc()->GetMasterSdPage(i, PageKind::Notes)->CreateTitleAndLayout(); - - pPage->CreateTitleAndLayout(); + return; } - nPageCnt = GetDoc()->GetSdPageCount(ePageKind); - - for (i = 0; i < nPageCnt; i++) - { - // then, handle all pages - pPage = GetDoc()->GetSdPage(i, ePageKind); - - SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage, - pPage->GetSize(), - pPage->GetLeftBorder(), pPage->GetRightBorder(), - pPage->GetUpperBorder(), pPage->GetLowerBorder(), - pPage->GetOrientation(), - pPage->GetPaperBin(), - pPage->IsBackgroundFullSize(), - rNewSize, - nLeft, nRight, - nUpper, nLower, - bScaleAll, - eOrientation, - nPaperBin, - bBackgroundFullSize); - pUndoGroup->AddAction(pUndo); - - if (rNewSize.Width() > 0 || - nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0) - { - ::tools::Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower); - pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll); - - if (rNewSize.Width() > 0) - pPage->SetSize(rNewSize); - } - - if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 ) - { - pPage->SetBorder(nLeft, nUpper, nRight, nLower); - } - - pPage->SetOrientation(eOrientation); - pPage->SetPaperBin( nPaperBin ); - pPage->SetBackgroundFullSize( bBackgroundFullSize ); - - if ( ePageKind == PageKind::Standard ) - { - SdPage* pNotesPage = GetDoc()->GetSdPage(i, PageKind::Notes); - pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() ); - } + SdUndoGroup* pUndoGroup(new SdUndoGroup(GetDoc())); + pUndoGroup->SetComment(SdResId(STR_UNDO_CHANGE_PAGEFORMAT)); + Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START)); - pPage->SetAutoLayout( pPage->GetAutoLayout() ); - } + // use Model-based method at SdDrawDocument + GetDoc()->AdaptPageSizeForAllPages( + rNewSize, + ePageKind, + pUndoGroup, + nLeft, + nRight, + nUpper, + nLower, + bScaleAll, + eOrientation, + nPaperBin, + bBackgroundFullSize); // adjust handout page to new format of the standard page - if( (ePageKind == PageKind::Standard) || (ePageKind == PageKind::Handout) ) + if(0 != nPageCnt && ((ePageKind == PageKind::Standard) || (ePageKind == PageKind::Handout))) + { GetDoc()->GetSdPage(0, PageKind::Handout)->CreateTitleAndLayout(true); + } // handed over undo group to undo manager - pViewShell->GetViewFrame()->GetObjectShell() - ->GetUndoManager()->AddUndoAction(pUndoGroup); + SfxViewShell* pViewShell(GetViewShell()); - long nWidth = pPage->GetSize().Width(); - long nHeight = pPage->GetSize().Height(); + if(nullptr != pViewShell) + { + pViewShell->GetViewFrame()->GetObjectShell()->GetUndoManager()->AddUndoAction(pUndoGroup); + } - Point aPageOrg(nWidth, nHeight / 2); - Size aViewSize(nWidth * 3, nHeight * 2); + // calculate View-Sizes + SdPage* pPage(0 != nPageCnt + ? GetDoc()->GetSdPage(0, ePageKind) + : GetDoc()->GetMasterSdPage(0, ePageKind)); + const long nWidth(pPage->GetSize().Width()); + const long nHeight(pPage->GetSize().Height()); + const Point aPageOrg(nWidth, nHeight / 2); + const Size aViewSize(nWidth * 3, nHeight * 2); + Point aVisAreaPos; + ::sd::View* pView(GetView()); + const Point aNewOrigin(pPage->GetLeftBorder(), pPage->GetUpperBorder()); InitWindows(aPageOrg, aViewSize, Point(-1, -1), true); - Point aVisAreaPos; - if ( GetDocSh()->GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) { aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft(); } - ::sd::View* pView = GetView(); if (pView) { pView->SetWorkArea(::tools::Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize)); @@ -610,20 +536,19 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize, UpdateScrollBars(); - Point aNewOrigin(pPage->GetLeftBorder(), pPage->GetUpperBorder()); - if (pView) { pView->GetSdrPageView()->SetPageOrigin(aNewOrigin); } - pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET); - - // zoom onto (new) page size - pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, - SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); + if(nullptr != pViewShell) + { + pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET); + // zoom onto (new) page size + pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); + } - Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END)); + Broadcast(ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END)); } /** -- cgit