| View previous topic :: View next topic |
| Author |
Message |
zzeric General User

Joined: 08 Apr 2010 Posts: 5
|
Posted: Sun Apr 11, 2010 12:55 am Post subject: How to print in reversed order in program? |
|
|
Here is the PrintSettings, and there is a PropertyValue named PrintReversed seems to be used in printing document in reversed order.
http://api.openoffice.org/docs/common/ref/com/sun/star/view/PrintSettings.html
So I wrote a class, here is a snap
| Code: |
// Load a Writer document, which will be automaticly displayed
com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
sUrl.toString(), "_blank", 0,
new PropertyValue[]{prop("ReadOnly",true),prop("Hidden",true)} );
com.sun.star.view.XPrintable xPrintable =
(com.sun.star.view.XPrintable)UnoRuntime.queryInterface(
com.sun.star.view.XPrintable.class, xComp);
xPrintable.setPrinter(new PropertyValue[]{prop("Name","PDFCreator"),prop("PrintReversed",true)});
xPrintable.print(new PropertyValue[] { prop("Pages", "1-10"),
prop("PrintReversed", true)} );
|
No matter where I put the PropertyValue in printer setting or print options, it still print in a normal order. Is it a bug? Or something is wrong in my code?
Thanks. |
|
| Back to top |
|
 |
zzeric General User

Joined: 08 Apr 2010 Posts: 5
|
Posted: Sun Apr 11, 2010 3:32 am Post subject: |
|
|
After debugging into the XPrintJob, I found that the PrintReversed propertyValue is in the print options, and the value is false。But I had set it true in the print method
| Code: |
xPrintable.print(new PropertyValue[] {
prop("Pages", "1-10"),
prop("PrintReversed", true)});
|
Then I lookup the source code of OpenOffice. In the unotxdoc.cxx
| Code: |
void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
throw( IllegalArgumentException, RuntimeException )
{
::vos::OGuard aGuard(Application::GetSolarMutex());
if(IsValid())
{
SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *pDocShell, 7, sal_True );
SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
pDocShell->GetDoc()->GetAttrPool());
aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True));
OUString sFileName( C2U(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME)));
OUString sCopyCount(C2U(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT)));
OUString sCollate(C2U(SW_PROP_NAME_STR(UNO_NAME_COLLATE)));
OUString sSort(C2U(SW_PROP_NAME_STR(UNO_NAME_SORT)));
OUString sPages(C2U(SW_PROP_NAME_STR(UNO_NAME_PAGES)));
for ( int n = 0; n < xOptions.getLength(); ++n )
{
// get Property-Value from options
const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
Any aValue( rProp.Value );
// FileName-Property?
if ( rProp.Name == sFileName )
{
OUString sFileURL;
if ( (rProp.Value >>= sFileURL ) )
{
// Convert the File URL into a system dependant path, as the SalPrinter expects
OUString sSystemPath;
FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
}
else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
throw IllegalArgumentException();
}
// CopyCount-Property
else if ( rProp.Name == sCopyCount )
{
sal_Int32 nCopies = 0;
aValue >>= nCopies;
aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
}
// Collate-Property
else if ( rProp.Name == sCollate )
{
if ( rProp.Value.getValueType() == ::getBooleanCppuType())
aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
else
throw IllegalArgumentException();
}
// Sort-Property
else if ( rProp.Name == sSort )
{
if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
else
throw IllegalArgumentException();
}
// Pages-Property
else if ( rProp.Name == sPages )
{
OUString sTmp;
if ( rProp.Value >>= sTmp )
aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
else
throw IllegalArgumentException();
}
}
pFrame->GetViewShell()->ExecuteSlot(aReq);
// Frame schliessen
pFrame->DoClose();
}
else
throw RuntimeException();
}
|
the print method just try to read 5 PopertyValue (FileName/CopyCount/Collate/Sort/Pages), the others was set in somewhere else.
So how to set the PrintReverse PropertyValue into the print options? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|