summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2017-11-27 13:51:55 +0100
committerKatarina Behrens <Katarina.Behrens@cib.de>2017-12-21 10:46:39 +0100
commit785a8564ebb501e2e623133e214467b947f7e671 (patch)
treeacb35956f393e3eafe8d983bb87cfd89bc6de1e8
parentbf8e8cf11bc0d60ab80f5b3420dc424aec2fa626 (diff)
tdf#79077: Load/save PapersizeFromSetup into ODF for sw and sc
Change-Id: I0fc1a771927dc7116768cfbb7f7e31006e41e1c8 Reviewed-on: https://gerrit.libreoffice.org/45332 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
-rw-r--r--sc/inc/unonames.hxx1
-rw-r--r--sc/source/ui/unoobj/confuno.cxx30
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.cxx18
-rw-r--r--sw/source/uibase/uno/SwXDocumentSettings.hxx1
4 files changed, 49 insertions, 1 deletions
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 6e104542f7dc..f8bf85968615 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -555,6 +555,7 @@
#define SC_UNO_AUTOCALC "AutoCalculate"
#define SC_UNO_PRINTERNAME "PrinterName"
#define SC_UNO_PRINTERSETUP "PrinterSetup"
+#define SC_UNO_PRINTERPAPER "PrinterPaperFromSetup"
#define SC_UNO_APPLYDOCINF "ApplyUserData"
#define SC_UNO_CHARCOMP "CharacterCompressionType"
#define SC_UNO_ASIANKERN "IsKernAsianPunctuation"
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index d2afa88c659e..6894813441e4 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -70,6 +70,7 @@ static const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
{OUString(SC_UNO_AUTOCALC), 0, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_PRINTERNAME), 0, cppu::UnoType<OUString>::get(), 0, 0},
{OUString(SC_UNO_PRINTERSETUP), 0, cppu::UnoType<uno::Sequence<sal_Int8>>::get(), 0, 0},
+ {OUString(SC_UNO_PRINTERPAPER), 0, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_APPLYDOCINF), 0, cppu::UnoType<bool>::get(), 0, 0},
{OUString(SC_UNO_FORBIDDEN), 0, cppu::UnoType<i18n::XForbiddenCharacters>::get(), beans::PropertyAttribute::READONLY, 0},
{OUString(SC_UNO_CHARCOMP), 0, cppu::UnoType<sal_Int16>::get(), 0, 0},
@@ -240,7 +241,28 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS>{} );
- pDocShell->SetPrinter( SfxPrinter::Create( aStream, std::move(pSet) ) );
+
+ SfxPrinter* pPrinter = pDocShell->GetPrinter();
+ bool bPreferPrinterPapersize = false;
+ if ( pPrinter )
+ bPreferPrinterPapersize = pPrinter->GetPrinterSettingsPreferred();
+
+ VclPtr<SfxPrinter> pTempPrinter = SfxPrinter::Create( aStream, std::move(pSet) );
+ pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
+ pDocShell->SetPrinter( pTempPrinter );
+ }
+ }
+ }
+ else if ( aPropertyName == SC_UNO_PRINTERPAPER )
+ {
+ bool bPreferPrinterPapersize;
+ if( aValue >>= bPreferPrinterPapersize )
+ {
+ if( pDocShell->GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
+ {
+ SfxPrinter *pTempPrinter = pDocShell->GetPrinter( true );
+ if (pTempPrinter)
+ pTempPrinter->SetPrinterSettingsPreferred( bPreferPrinterPapersize );
}
}
}
@@ -462,6 +484,12 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPr
else
aRet <<= uno::Sequence<sal_Int8>();
}
+ else if ( aPropertyName == SC_UNO_PRINTERPAPER)
+ {
+ SfxPrinter *pTempPrinter = pDocShell->GetPrinter( false );
+ aRet <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred();
+
+ }
else if ( aPropertyName == SC_UNO_APPLYDOCINF )
aRet <<= pDocShell->IsUseUserData();
else if ( aPropertyName == SC_UNO_FORBIDDEN )
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index ee86063fea52..d7009cd20b26 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -74,6 +74,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_ALIGN_TAB_STOP_POSITION,
HANDLE_PRINTER_NAME,
HANDLE_PRINTER_SETUP,
+ HANDLE_PRINTER_PAPER,
HANDLE_IS_KERN_ASIAN_PUNCTUATION,
HANDLE_CHARACTER_COMPRESSION_TYPE,
HANDLE_APPLY_USER_DATA,
@@ -150,6 +151,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0},
{ OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0},
{ OUString("PrinterSetup"), HANDLE_PRINTER_SETUP, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0},
+ { OUString("PrinterPaperFromSetup"), HANDLE_PRINTER_PAPER, cppu::UnoType<bool>::get(), 0},
{ OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0},
{ OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0},
{ OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0},
@@ -248,6 +250,7 @@ SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel )
, mpDocSh ( nullptr )
, mpDoc ( nullptr )
, mpPrinter( nullptr )
+, mbPreferPrinterPapersize( false )
{
registerSlave ( new SwXPrintSettings ( SwXPrintSettingsType::Document, mpModel->GetDocShell()->GetDoc() ) );
}
@@ -441,6 +444,14 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
}
break;
+ case HANDLE_PRINTER_PAPER:
+ {
+ bool bPreferPrinterPapersize;
+ if(!(rValue >>= bPreferPrinterPapersize))
+ throw IllegalArgumentException();
+ mbPreferPrinterPapersize = bPreferPrinterPapersize;
+ }
+ break;
case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
{
bool bIsKern = *o3tl::doAccess<bool>(rValue);
@@ -884,6 +895,7 @@ void SwXDocumentSettings::_postSetValues ()
SwAddPrinterItem aAddPrinterItem (aPrtData);
aOptions.Put(aAddPrinterItem);
mpPrinter->SetOptions( aOptions );
+ mpPrinter->SetPrinterSettingsPreferred( mbPreferPrinterPapersize );
mpDoc->getIDocumentDeviceAccess().setPrinter( mpPrinter, true, true );
}
@@ -972,6 +984,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
}
}
break;
+ case HANDLE_PRINTER_PAPER:
+ {
+ SfxPrinter *pTempPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( false );
+ rValue <<= pTempPrinter && pTempPrinter->GetPrinterSettingsPreferred();
+ }
+ break;
case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
{
rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::KERN_ASIAN_PUNCTUATION);
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.hxx b/sw/source/uibase/uno/SwXDocumentSettings.hxx
index 5c9e28c78302..6f4adc542f2f 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.hxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.hxx
@@ -45,6 +45,7 @@ class SwXDocumentSettings final :
* printer-related properties, remember the last printer and set it in
* _postSetValues */
VclPtr<SfxPrinter> mpPrinter;
+ bool mbPreferPrinterPapersize;
virtual void _preSetValues () override;
virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const css::uno::Any &rValue ) override;