[Libreoffice-commits] .: 2 commits - sfx2/source vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Jun 26 07:59:45 PDT 2012
sfx2/source/view/viewprn.cxx | 89 +++++++++++++++++++++++------------------
vcl/source/window/printdlg.cxx | 3 +
2 files changed, 54 insertions(+), 38 deletions(-)
New commits:
commit 7db0ac29c0962932bbcd8b460dc51c9e5009dbfa
Author: Maxime de Roucy <mderoucy at linagora.com>
Date: Tue Jun 26 15:52:41 2012 +0100
Prevent print settings dialog to show help button
Prevent the printer settings dialog to show help button when it's called
from the help.
Add a PrinterController property : HideHelpButton
Change-Id: I45585a30a2f429659f554747f93c650cb048711f
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 239c300..cb8a2e8 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -671,8 +671,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
bSilent = pSilentItem && pSilentItem->GetValue();
}
- //FIXME: how to transport "bPrintOnHelp"?
-
// no help button in dialogs if called from the help window
// (pressing help button would exchange the current page inside the help
// document that is going to be printed!)
@@ -744,6 +742,11 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
}
}
+ // we will add the "PrintSelectionOnly" or "HideHelpButton" properties
+ // we have to increase the capacity of aProps
+ sal_Int32 nLen = aProps.getLength();
+ aProps.realloc( nLen + 1 );
+
// HACK: writer sets the SID_SELECTION item when printing directly and expects
// to get only the selection document in that case (see getSelectionObject)
// however it also reacts to the PrintContent property. We need this distinction here, too,
@@ -755,11 +758,15 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False);
sal_Bool bSelection = ( pSelectItem != NULL && pSelectItem->GetValue() );
- sal_Int32 nLen = aProps.getLength();
- aProps.realloc( nLen + 1 );
aProps[nLen].Name = rtl::OUString( "PrintSelectionOnly" );
aProps[nLen].Value = makeAny( bSelection );
}
+ else // if nId == SID_PRINTDOC ; nothing to do with the previous HACK
+ {
+ // should the printer selection and properties dialogue display an help button
+ aProps[nLen].Name = rtl::OUString( "HideHelpButton" );
+ aProps[nLen].Value = makeAny( bPrintOnHelp );
+ }
ExecPrint( aProps, bIsAPI, (nId == SID_PRINTDOCDIRECT) );
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index d9aa5dd..9c05203 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -902,6 +902,9 @@ PrintDialog::PrintDialog( Window* i_pParent, const boost::shared_ptr<PrinterCont
// setup dependencies
checkControlDependencies();
+ if ( maPController->getBoolProperty( rtl::OUString( "HideHelpButton" ), sal_False ) )
+ maHelpButton.Hide();
+
// set initial focus to "Number of copies"
maJobPage.maCopyCountField.GrabFocus();
maJobPage.maCopyCountField.SetSelection( Selection(0, 0xFFFF) );
commit 512b195910a7f73206c50a89ec5fc62cced49ace
Author: Maxime de Roucy <mderoucy at linagora.com>
Date: Tue Jun 26 15:50:52 2012 +0100
Some rewriting in SfxViewShell::ExecPrint_Impl
* add comments
* reorganise if statement
* use of the IsAPI function
* prevent segfault (NULLÂ pointer dereferencing)
Change-Id: I79b010e676ea5efc23903d6c63e04175871d1258
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 909b54e..239c300 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -137,7 +137,7 @@ SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_
// initialize extra ui options
if( mxRenderable.is() )
{
- for (sal_Int32 nProp=0; nProp<rProps.getLength(); nProp++)
+ for (sal_Int32 nProp=0; nProp < rProps.getLength(); ++nProp)
setValue( rProps[nProp].Name, rProps[nProp].Value );
Sequence< beans::PropertyValue > aRenderOptions( 3 );
@@ -654,13 +654,19 @@ Printer* SfxViewShell::GetActivePrinter() const
void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
{
- sal_uInt16 nDialogRet = RET_CANCEL;
+ sal_uInt16 nDialogRet = RET_CANCEL;
SfxPrinter* pPrinter = 0;
SfxDialogExecutor_Impl* pExecutor = 0;
bool bSilent = false;
- sal_Bool bIsAPI = rReq.GetArgs() && rReq.GetArgs()->Count();
+
+ // does the function have been called by the user interface or by an API call
+ sal_Bool bIsAPI = rReq.IsAPI();
if ( bIsAPI )
{
+ // the function have been called by the API
+
+ // Should it be visible on the user interface,
+ // should it launch popup dialogue ?
SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, sal_False);
bSilent = pSilentItem && pSilentItem->GetValue();
}
@@ -678,27 +684,20 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
const sal_uInt16 nId = rReq.GetSlot();
switch( nId )
{
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- case SID_PRINTDOC:
- case SID_PRINTDOCDIRECT:
+ case SID_PRINTDOC: // display the printer selection and properties dialogue : File > Printâ¦
+ case SID_PRINTDOCDIRECT: // Print the document directly, without displaying the dialogue
{
SfxObjectShell* pDoc = GetObjectShell();
// derived class may decide to abort this
- if( !pDoc->QuerySlotExecutable( nId ) )
+ if( pDoc == NULL || !pDoc->QuerySlotExecutable( nId ) )
{
rReq.SetReturnValue( SfxBoolItem( 0, sal_False ) );
return;
}
- bool bDetectHidden = ( !bSilent && pDoc );
- if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
- break;
-
- SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False);
- sal_Bool bSelection = pSelectItem && pSelectItem->GetValue();
- if( pSelectItem && rReq.GetArgs()->Count() == 1 )
- bIsAPI = sal_False;
+ if ( !bSilent && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES )
+ return;
uno::Sequence < beans::PropertyValue > aProps;
if ( bIsAPI )
@@ -714,21 +713,28 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// bool Asynchron
// bool Collate
// bool Silent
+
+ // the TransformItems function overwrite aProps
TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) );
- for ( sal_Int32 nProp=0; nProp<aProps.getLength(); nProp++ )
+
+ for ( sal_Int32 nProp=0; nProp < aProps.getLength(); ++nProp )
{
if ( aProps[nProp].Name == "Copies" )
+ {
aProps[nProp]. Name = rtl::OUString("CopyCount");
+ }
else if ( aProps[nProp].Name == "RangeText" )
+ {
aProps[nProp]. Name = rtl::OUString("Pages");
- if ( aProps[nProp].Name == "Asynchron" )
+ }
+ else if ( aProps[nProp].Name == "Asynchron" )
{
aProps[nProp]. Name = rtl::OUString("Wait");
sal_Bool bAsynchron = sal_False;
aProps[nProp].Value >>= bAsynchron;
aProps[nProp].Value <<= (sal_Bool) (!bAsynchron);
}
- if ( aProps[nProp].Name == "Silent" )
+ else if ( aProps[nProp].Name == "Silent" )
{
aProps[nProp]. Name = rtl::OUString("MonitorVisible");
sal_Bool bPrintSilent = sal_False;
@@ -737,6 +743,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
}
}
}
+
// HACK: writer sets the SID_SELECTION item when printing directly and expects
// to get only the selection document in that case (see getSelectionObject)
// however it also reacts to the PrintContent property. We need this distinction here, too,
@@ -744,6 +751,10 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// it would be better if writer handled this internally
if( nId == SID_PRINTDOCDIRECT )
{
+ // should we print only the selection or the whole document
+ SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, sal_False);
+ sal_Bool bSelection = ( pSelectItem != NULL && pSelectItem->GetValue() );
+
sal_Int32 nLen = aProps.getLength();
aProps.realloc( nLen + 1 );
aProps[nLen].Name = rtl::OUString( "PrintSelectionOnly" );
@@ -756,8 +767,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
rReq.Done();
break;
}
-
- case SID_SETUPPRINTER :
+ case SID_SETUPPRINTER : // display the printer settings dialogue : File > Printer Settingsâ¦
case SID_PRINTER_NAME : // only for recorded macros
{
// get printer and printer settings from the document
@@ -771,7 +781,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
pPrinter = new SfxPrinter( pDocPrinter->GetOptions().Clone(), ((const SfxStringItem*) pPrinterItem)->GetValue() );
// if printer is unknown, it can't be used - now printer from document will be used
- if ( !pPrinter->IsOriginal() )
+ if ( !pPrinter->IsKnown() )
DELETEZ(pPrinter);
}
@@ -780,7 +790,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
// just set a recorded printer name
if ( pPrinter )
SetPrinter( pPrinter, SFX_PRINTER_PRINTER );
- break;
+ return;
}
// no PrinterName parameter in ItemSet or the PrinterName points to an unknown printer
@@ -791,23 +801,23 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
if( !pPrinter || !pPrinter->IsValid() )
{
// no valid printer either in ItemSet or at the document
- if ( bSilent )
- {
- rReq.SetReturnValue(SfxBoolItem(0,sal_False));
- break;
- }
- else
+ if ( !bSilent )
ErrorBox( NULL, WB_OK | WB_DEF_OK, SfxResId(STR_NODEFPRINTER).toString() ).Execute();
+
+ rReq.SetReturnValue(SfxBoolItem(0,sal_False));
+
+ break;
}
// FIXME: printer isn't used for printing anymore!
if( pPrinter->IsPrinting() )
{
- // if printer is busy, abort printing
+ // if printer is busy, abort configuration
if ( !bSilent )
InfoBox( NULL, SfxResId(STR_ERROR_PRINTER_BUSY).toString() ).Execute();
rReq.SetReturnValue(SfxBoolItem(0,sal_False));
- break;
+
+ return;
}
// if no arguments are given, retrieve them from a dialog
@@ -879,14 +889,10 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
if ( SID_PRINTDOC == nId )
rReq.SetReturnValue(SfxBoolItem(0,sal_False));
if ( nId == SID_SETUPPRINTER )
- {
rReq.AppendItem( SfxBoolItem( SID_DIALOG_RETURN, sal_False ) );
- }
}
}
}
-
- break;
}
}
More information about the Libreoffice-commits
mailing list