Kaydet (Commit) b743d446 authored tarafından Muhammet Kara's avatar Muhammet Kara

tdf#125063: Don't depend on content size for Page sizing

During redaction of Calc sheets

Change-Id: If2a4f71c77a687a74b8f823152b76d2a7e2e21da
Reviewed-on: https://gerrit.libreoffice.org/71627
Tested-by: Jenkins
Reviewed-by: 's avatarMuhammet Kara <muhammet.kara@collabora.com>
üst e6532f75
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <sal/types.h> #include <sal/types.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <tools/gen.hxx>
#include <vector> #include <vector>
...@@ -47,7 +48,7 @@ public: ...@@ -47,7 +48,7 @@ public:
* and pushes into the given vector. * and pushes into the given vector.
* */ * */
static void getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles, static void getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles,
const sal_Int32& nPages, std::vector<::Size>& aPageSizes, const sal_Int32& nPages,
DocumentToGraphicRenderer& aRenderer, bool bIsWriter, DocumentToGraphicRenderer& aRenderer, bool bIsWriter,
bool bIsCalc); bool bIsCalc);
/* /*
...@@ -55,7 +56,8 @@ public: ...@@ -55,7 +56,8 @@ public:
* and inserts the shapes into the newly created draw pages. * and inserts the shapes into the newly created draw pages.
* */ * */
static void addPagesToDraw(uno::Reference<XComponent>& xComponent, const sal_Int32& nPages, static void addPagesToDraw(uno::Reference<XComponent>& xComponent, const sal_Int32& nPages,
const std::vector<GDIMetaFile>& aMetaFiles, bool bIsCalc); const std::vector<GDIMetaFile>& aMetaFiles,
const std::vector<::Size>& aPageSizes, bool bIsCalc);
/* /*
* Makes the Redaction toolbar visible to the user. * Makes the Redaction toolbar visible to the user.
* Meant to be called after converting a document to a Draw doc * Meant to be called after converting a document to a Draw doc
......
...@@ -62,6 +62,7 @@ OUString SfxRedactionHelper::getStringParam(const SfxRequest& rReq, const sal_uI ...@@ -62,6 +62,7 @@ OUString SfxRedactionHelper::getStringParam(const SfxRequest& rReq, const sal_uI
} }
void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles, void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMetaFiles,
std::vector<::Size>& aPageSizes,
const sal_Int32& nPages, const sal_Int32& nPages,
DocumentToGraphicRenderer& aRenderer, DocumentToGraphicRenderer& aRenderer,
bool bIsWriter, bool bIsCalc) bool bIsWriter, bool bIsCalc)
...@@ -77,6 +78,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMeta ...@@ -77,6 +78,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMeta
// FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor. // FIXME: This is a temporary hack. Need to figure out a proper way to derive this scale factor.
::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23); ::Size aTargetSize(aDocumentSizePixel.Width() * 1.23, aDocumentSizePixel.Height() * 1.23);
aPageSizes.push_back(aLogic);
Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aTargetSize, Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aTargetSize,
COL_TRANSPARENT, true); COL_TRANSPARENT, true);
auto& rGDIMetaFile = const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile()); auto& rGDIMetaFile = const_cast<GDIMetaFile&>(aGraphic.GetGDIMetaFile());
...@@ -110,7 +113,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMeta ...@@ -110,7 +113,8 @@ void SfxRedactionHelper::getPageMetaFilesFromDoc(std::vector<GDIMetaFile>& aMeta
void SfxRedactionHelper::addPagesToDraw(uno::Reference<XComponent>& xComponent, void SfxRedactionHelper::addPagesToDraw(uno::Reference<XComponent>& xComponent,
const sal_Int32& nPages, const sal_Int32& nPages,
const std::vector<GDIMetaFile>& aMetaFiles, bool bIsCalc) const std::vector<GDIMetaFile>& aMetaFiles,
const std::vector<::Size>& aPageSizes, bool bIsCalc)
{ {
// Access the draw pages // Access the draw pages
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY); uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
...@@ -123,8 +127,8 @@ void SfxRedactionHelper::addPagesToDraw(uno::Reference<XComponent>& xComponent, ...@@ -123,8 +127,8 @@ void SfxRedactionHelper::addPagesToDraw(uno::Reference<XComponent>& xComponent,
GDIMetaFile rGDIMetaFile = aMetaFiles[nPage]; GDIMetaFile rGDIMetaFile = aMetaFiles[nPage];
Graphic aGraphic(rGDIMetaFile); Graphic aGraphic(rGDIMetaFile);
sal_Int32 nPageHeight(rGDIMetaFile.GetPrefSize().Height()); sal_Int32 nPageHeight(aPageSizes[nPage].Height());
sal_Int32 nPageWidth(rGDIMetaFile.GetPrefSize().Width()); sal_Int32 nPageWidth(aPageSizes[nPage].Width());
uno::Reference<graphic::XGraphic> xGraph = aGraphic.GetXGraphic(); uno::Reference<graphic::XGraphic> xGraph = aGraphic.GetXGraphic();
uno::Reference<drawing::XDrawPage> xPage = xDrawPages->insertNewByIndex(nPage); uno::Reference<drawing::XDrawPage> xPage = xDrawPages->insertNewByIndex(nPage);
......
...@@ -561,9 +561,10 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) ...@@ -561,9 +561,10 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
sal_Int32 nPages = aRenderer.getPageCount(); sal_Int32 nPages = aRenderer.getPageCount();
std::vector< GDIMetaFile > aMetaFiles; std::vector< GDIMetaFile > aMetaFiles;
std::vector< ::Size > aPageSizes;
// Convert the pages of the document to gdimetafiles // Convert the pages of the document to gdimetafiles
SfxRedactionHelper::getPageMetaFilesFromDoc(aMetaFiles, nPages, aRenderer, bIsWriter, bIsCalc); SfxRedactionHelper::getPageMetaFilesFromDoc(aMetaFiles, aPageSizes, nPages, aRenderer, bIsWriter, bIsCalc);
// Create an empty Draw component. // Create an empty Draw component.
uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext()); uno::Reference<frame::XDesktop2> xDesktop = css::frame::Desktop::create(comphelper::getProcessComponentContext());
...@@ -571,7 +572,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) ...@@ -571,7 +572,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
uno::Reference<lang::XComponent> xComponent = xComponentLoader->loadComponentFromURL("private:factory/sdraw", "_default", 0, {}); uno::Reference<lang::XComponent> xComponent = xComponentLoader->loadComponentFromURL("private:factory/sdraw", "_default", 0, {});
// Add the doc pages to the new draw document // Add the doc pages to the new draw document
SfxRedactionHelper::addPagesToDraw(xComponent, nPages, aMetaFiles, bIsCalc); SfxRedactionHelper::addPagesToDraw(xComponent, nPages, aMetaFiles, aPageSizes, bIsCalc);
// Show the Redaction toolbar // Show the Redaction toolbar
SfxViewFrame* pViewFrame = SfxViewFrame::Current(); SfxViewFrame* pViewFrame = SfxViewFrame::Current();
......
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