summaryrefslogtreecommitdiff
path: root/sd/source
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-10 17:49:19 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-05-18 20:11:35 +0200
commit3ca7be09834a26fbd1c371deabd7a58111092676 (patch)
tree560c1ee287e529b8879bbc2375b5a48f87c65a51 /sd/source
parentc845135b7b605257b5c94b382d88627282cb05a3 (diff)
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 <ci@libreoffice.org> Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'sd/source')
-rw-r--r--sd/source/core/drawdoc.cxx176
-rw-r--r--sd/source/ui/view/viewshe2.cxx167
2 files changed, 221 insertions, 122 deletions
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index 36d6a82e251e..0c152e067594 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -96,7 +96,8 @@
#include <optsitem.hxx>
#include <FrameView.hxx>
#include <undo/undomanager.hxx>
-
+#include <sdundogr.hxx>
+#include <undopage.hxx>
#include <tools/tenccvt.hxx>
#include <vcl/settings.hxx>
@@ -392,6 +393,179 @@ SdDrawDocument::~SdDrawDocument()
mpCharClass.reset();
}
+void SdDrawDocument::adaptSizeAndBorderForAllPages(
+ const Size& rNewSize,
+ long nLeft,
+ long nRight,
+ long nUpper,
+ long nLower)
+{
+ const sal_uInt16 nMasterPageCnt(GetMasterSdPageCount(PageKind::Standard));
+ const sal_uInt16 nPageCnt(GetSdPageCount(PageKind::Standard));
+
+ if(0 == nMasterPageCnt && 0 == nPageCnt)
+ {
+ return;
+ }
+
+ SdPage* pPage(0 != nPageCnt ? GetSdPage(0, PageKind::Standard) : GetMasterSdPage(0, PageKind::Standard));
+
+ // call fully implemented local version, including getting
+ // some more information from one of the Pages (1st one)
+ AdaptPageSizeForAllPages(
+ rNewSize,
+ PageKind::Standard,
+ nullptr,
+ nLeft,
+ nRight,
+ nUpper,
+ nLower,
+ true,
+ pPage->GetOrientation(),
+ pPage->GetPaperBin(),
+ pPage->IsBackgroundFullSize());
+
+ // adjust handout page to new format of the standard page
+ if(0 != nPageCnt)
+ {
+ GetSdPage(0, PageKind::Handout)->CreateTitleAndLayout(true);
+ }
+}
+
+void SdDrawDocument::AdaptPageSizeForAllPages(
+ const Size& rNewSize,
+ PageKind ePageKind,
+ SdUndoGroup* pUndoGroup,
+ long nLeft,
+ long nRight,
+ long nUpper,
+ long nLower,
+ bool bScaleAll,
+ Orientation eOrientation,
+ sal_uInt16 nPaperBin,
+ bool bBackgroundFullSize)
+{
+ sal_uInt16 i;
+ const sal_uInt16 nMasterPageCnt(GetMasterSdPageCount(ePageKind));
+ const sal_uInt16 nPageCnt(GetSdPageCount(ePageKind));
+
+ if(0 == nMasterPageCnt && 0 == nPageCnt)
+ {
+ return;
+ }
+
+ for (i = 0; i < nMasterPageCnt; i++)
+ {
+ // first, handle all master pages
+ SdPage* pPage(GetMasterSdPage(i, ePageKind));
+
+ if(pUndoGroup)
+ {
+ SdUndoAction* pUndo(
+ new SdPageFormatUndoAction(
+ this,
+ 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 )
+ {
+ GetMasterSdPage(i, PageKind::Notes)->CreateTitleAndLayout();
+ }
+
+ pPage->CreateTitleAndLayout();
+ }
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ // then, handle all pages
+ SdPage* pPage(GetSdPage(i, ePageKind));
+
+ if(pUndoGroup)
+ {
+ SdUndoAction* pUndo(
+ new SdPageFormatUndoAction(
+ this,
+ 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 = GetSdPage(i, PageKind::Notes);
+ pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
+ }
+
+ pPage->SetAutoLayout( pPage->GetAutoLayout() );
+ }
+}
+
SdrModel* SdDrawDocument::AllocModel() const
{
return AllocSdDrawDocument();
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));
}
/**