[Libreoffice-commits] core.git: filter/source sc/source
Muhammet Kara (via logerrit)
logerrit at kemper.freedesktop.org
Fri Oct 11 08:14:25 UTC 2019
filter/source/pdf/pdfexport.cxx | 6 +
sc/source/ui/unoobj/docuno.cxx | 131 ++++++++++++++++++++++++++++++++++++++--
2 files changed, 131 insertions(+), 6 deletions(-)
New commits:
commit c11d96f0b521ee7df77576963b60178d2c40431b
Author: Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Sep 30 20:39:39 2019 +0300
Commit: Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Fri Oct 11 10:13:22 2019 +0200
Handle SinglePageSheets option for pdf export
When the single page sheets option is selected
on the pdf export dialog of Calc, a pdf for general
preview of the document is created, which is not
meant for printing.
Each sheet is exported as a single page, thus causing
the resulting pdf to have pages with different sizes.
This is a follow-up to commit 079cd016408d54d91
Change-Id: I038761f06bbf4b0425df89bcda4ee111a61be1d5
Reviewed-on: https://gerrit.libreoffice.org/79895
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/80635
Tested-by: Jenkins
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index b0a91ace6e4f..2cf302bda668 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -860,7 +860,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
pPDFExtOutDevData->SetIsReduceImageResolution( mbReduceImageResolution );
pPDFExtOutDevData->SetIsExportNamedDestinations( mbExportBmkToDest );
- Sequence< PropertyValue > aRenderOptions( 7 );
+ Sequence< PropertyValue > aRenderOptions( 8 );
aRenderOptions[ 0 ].Name = "RenderDevice";
aRenderOptions[ 0 ].Value <<= uno::Reference<awt::XDevice>(xDevice.get());
aRenderOptions[ 1 ].Name = "ExportNotesPages";
@@ -876,6 +876,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
aRenderOptions[ 5 ].Value <<= aPageRange;
aRenderOptions[ 6 ].Name = "ExportPlaceholders";
aRenderOptions[ 6 ].Value <<= mbExportPlaceholders;
+ aRenderOptions[ 7 ].Name = "SinglePageSheets";
+ aRenderOptions[ 7 ].Value <<= mbSinglePageSheets;
if( !aPageRange.isEmpty() || !aSelection.hasValue() )
{
@@ -925,7 +927,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
}
const bool bExportPages = !bExportNotesPages || !mbExportOnlyNotesPages;
- if( aPageRange.isEmpty() )
+ if( aPageRange.isEmpty() || mbSinglePageSheets)
{
aPageRange = OUString::number( 1 ) + "-" + OUString::number(nPageCount );
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 58fdad8890f2..e312f9e59ea5 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1594,13 +1594,22 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection,
maValidPages.clear();
sal_Int32 nContent = 0;
+ bool bSinglePageSheets = false;
for ( const auto& rValue : rOptions)
{
if ( rValue.Name == "PrintRange" )
{
rValue.Value >>= nContent;
- break;
}
+ else if ( rValue.Name == "SinglePageSheets" )
+ {
+ rValue.Value >>= bSinglePageSheets;
+ }
+ }
+
+ if (bSinglePageSheets)
+ {
+ return pDocShell->GetDocument().GetTableCount();
}
bool bIsPrintEvenPages = nContent != 3;
@@ -1660,6 +1669,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
// #i115266# if FillRenderMarkData fails, keep nTotalPages at 0, but still handle getRenderer(0) below
long nTotalPages = 0;
bool bRenderToGraphic = false;
+ bool bSinglePageSheets = false;
if ( FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
{
if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
@@ -1668,7 +1678,21 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
}
nTotalPages = pPrintFuncCache->GetPageCount();
}
+
+ for ( const auto& rValue : rOptions)
+ {
+ if ( rValue.Name == "SinglePageSheets" )
+ {
+ rValue.Value >>= bSinglePageSheets;
+ break;
+ }
+ }
+
+ if (bSinglePageSheets)
+ nTotalPages = pDocShell->GetDocument().GetTableCount();
+
sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
+
if ( nRenderer < 0 )
{
if ( nSelRenderer != 0 )
@@ -1713,7 +1737,9 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
// printer is used as device (just for page layout), draw view is not needed
SCTAB nTab;
- if ( !maValidPages.empty() )
+ if (bSinglePageSheets)
+ nTab = nSelRenderer;
+ else if ( !maValidPages.empty() )
nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 );
else
nTab = pPrintFuncCache->GetTabForPage( nRenderer );
@@ -1721,7 +1747,56 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
ScRange aRange;
const ScRange* pSelRange = nullptr;
- if ( aMark.IsMarked() )
+ if ( bSinglePageSheets )
+ {
+ awt::Size aPageSize;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ const ScDocument* pDocument = &pDocShell->GetDocument();
+ pDocument->GetDataStart( nTab, nStartCol, nStartRow );
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDocument->GetPrintArea( nTab, nEndCol, nEndRow );
+
+ aRange.aStart = ScAddress(nStartCol, nStartRow, nTab);
+ aRange.aEnd = ScAddress(nEndCol, nEndRow, nTab);
+ pSelRange = &aRange;
+
+ table::CellRangeAddress aRangeAddress( nTab,
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() );
+ tools::Rectangle aMMRect( pDocShell->GetDocument().GetMMRect(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab()));
+
+ aPageSize.Width = aMMRect.GetWidth();
+ aPageSize.Height = aMMRect.GetHeight();
+
+ awt::Size aCalcPageSize ( aMMRect.GetSize().Width(), aMMRect.GetSize().Height() );
+ awt::Point aCalcPagePos( aMMRect.getX(), aMMRect.getY() );
+
+ uno::Sequence<beans::PropertyValue> aSequence(5);
+ beans::PropertyValue* pArray = aSequence.getArray();
+ pArray[0].Name = SC_UNONAME_PAGESIZE;
+ pArray[0].Value <<= aPageSize;
+ // #i111158# all positions are relative to the whole page, including non-printable area
+ pArray[1].Name = SC_UNONAME_INC_NP_AREA;
+ pArray[1].Value <<= true;
+ pArray[2].Name = SC_UNONAME_SOURCERANGE;
+ pArray[2].Value <<= aRangeAddress;
+ pArray[3].Name = SC_UNONAME_CALCPAGESIZE;
+ pArray[3].Value <<= aCalcPageSize;
+ pArray[4].Name = SC_UNONAME_CALCPAGEPOS;
+ pArray[4].Value <<= aCalcPagePos;
+
+ if( ! pPrinterOptions )
+ pPrinterOptions.reset(new ScPrintUIOptions);
+ else
+ pPrinterOptions->SetDefaults();
+ pPrinterOptions->appendPrintUIOptions( aSequence );
+ return aSequence;
+ }
+ else if ( aMark.IsMarked() )
{
aMark.GetMarkArea( aRange );
pSelRange = &aRange;
@@ -1840,6 +1915,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
ScPrintSelectionStatus aStatus;
OUString aPagesStr;
bool bRenderToGraphic = false;
+ bool bSinglePageSheets = false;
if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr, bRenderToGraphic ) )
throw lang::IllegalArgumentException();
@@ -1848,6 +1924,19 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus ));
}
long nTotalPages = pPrintFuncCache->GetPageCount();
+
+ for ( const auto& rValue : rOptions)
+ {
+ if ( rValue.Name == "SinglePageSheets" )
+ {
+ rValue.Value >>= bSinglePageSheets;
+ break;
+ }
+ }
+
+ if (bSinglePageSheets)
+ nTotalPages = pDocShell->GetDocument().GetTableCount();
+
sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
if ( nRenderer < 0 )
throw lang::IllegalArgumentException();
@@ -1860,7 +1949,39 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
ScRange aRange;
const ScRange* pSelRange = nullptr;
- if ( aMark.IsMarked() )
+ if ( bSinglePageSheets )
+ {
+ awt::Size aPageSize;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ rDoc.GetDataStart( nSelRenderer, nStartCol, nStartRow );
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ rDoc.GetPrintArea( nSelRenderer, nEndCol, nEndRow );
+
+ aRange.aStart = ScAddress(nStartCol, nStartRow, nSelRenderer);
+ aRange.aEnd = ScAddress(nEndCol, nEndRow, nSelRenderer);
+
+ tools::Rectangle aMMRect( pDocShell->GetDocument().GetMMRect(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab()));
+
+ aPageSize.Width = aMMRect.GetWidth();
+ aPageSize.Height = aMMRect.GetHeight();
+
+ //Set visible tab
+ SCTAB nVisTab = rDoc.GetVisibleTab();
+ if (nVisTab != nSelRenderer)
+ {
+ nVisTab = nSelRenderer;
+ rDoc.SetVisibleTab(nVisTab);
+ }
+
+ pDocShell->DoDraw(pDev, Point(0,0), Size(aPageSize.Width, aPageSize.Height), JobSetup());
+
+ return;
+ }
+ else if ( aMark.IsMarked() )
{
aMark.GetMarkArea( aRange );
pSelRange = &aRange;
@@ -1902,6 +2023,8 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
} aDrawViewKeeper;
SCTAB nTab;
+ if (bSinglePageSheets)
+ nTab = nSelRenderer;
if ( !maValidPages.empty() )
nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 );
else
More information about the Libreoffice-commits
mailing list