vcl118: #i115048# revert brochure printing in writer to old behavior taking the paper size form the printer driver, add paper name to print preview

This commit is contained in:
Philipp Lohmann [pl] 2011-01-19 16:33:54 +01:00
parent f25576b919
commit cc01ab8a81
8 changed files with 114 additions and 4 deletions

View file

@ -340,6 +340,9 @@ public:
BOOL SetPaperSizeUser( const Size& rSize );
BOOL SetPaperSizeUser( const Size& rSize, bool bMatchNearest );
Paper GetPaper() const;
static rtl::OUString GetPaperName( Paper ePaper );
// return a UI string for the current paper; i_bPaperUser == false means an empty string for PAPER_USER
rtl::OUString GetPaperName( bool i_bPaperUser = true ) const;
// returns number of available paper formats
int GetPaperInfoCount() const;

View file

@ -73,7 +73,9 @@ namespace vcl
virtual void Resize();
virtual void DataChanged( const DataChangedEvent& );
void setPreview( const GDIMetaFile&, const Size&, const rtl::OUString&,
void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
const rtl::OUString& i_rPaperName,
const rtl::OUString& i_rNoPageString,
sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
bool i_bGreyscale
);

View file

@ -43,6 +43,8 @@
#include "com/sun/star/uno/Reference.hxx"
#include "unotools/options.hxx"
#include <hash_map>
namespace com {
namespace sun {
namespace star {
@ -365,14 +367,15 @@ struct ImplSVData
com::sun::star::uno::Reference< com::sun::star::frame::XSessionManagerClient > xSMClient;
::vcl::SettingsConfigItem* mpSettingsConfigItem;
std::list< vcl::DeleteOnDeinitBase* >* mpDeinitDeleteList;
std::hash_map< int, rtl::OUString >* mpPaperNames;
};
void ImplInitSVData();
void ImplDeInitSVData();
void ImplDestroySVData();
Window* ImplGetDefaultWindow();
VCL_DLLPUBLIC ResMgr* ImplGetResMgr();
VCL_DLLPUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr
VCL_PLUGIN_PUBLIC ResMgr* ImplGetResMgr();
VCL_PLUGIN_PUBLIC ResId VclResId( sal_Int32 nId ); // throws std::bad_alloc if no res mgr
DockingManager* ImplGetDockingManager();
void ImplWindowAutoMnemonic( Window* pWindow );

View file

@ -58,6 +58,8 @@
#define SV_DISCLOSURE_PLUS_HC 1062
#define SV_DISCLOSURE_MINUS_HC 1063
#define RID_STR_PAPERNAMES 1070
#define SV_RESID_MENU_EDIT 2000
#define SV_MENU_EDIT_UNDO 1
#define SV_MENU_EDIT_CUT 2

View file

@ -179,6 +179,8 @@ void ImplDeInitSVData()
delete pSVData->maCtrlData.mpFieldUnitStrings, pSVData->maCtrlData.mpFieldUnitStrings = NULL;
if( pSVData->maCtrlData.mpCleanUnitStrings )
delete pSVData->maCtrlData.mpCleanUnitStrings, pSVData->maCtrlData.mpCleanUnitStrings = NULL;
if( pSVData->mpPaperNames )
delete pSVData->mpPaperNames, pSVData->mpPaperNames = NULL;
}
// -----------------------------------------------------------------------

View file

@ -41,6 +41,7 @@
#include <vcl/unohelp.hxx>
#include <tools/debug.hxx>
#include <tools/resary.hxx>
#include <tools/stream.hxx>
#include <tools/vcompat.hxx>
#include <vcl/svdata.hxx>
@ -54,6 +55,7 @@
#include <vcl/gdimtf.hxx>
#include <vcl/metaact.hxx>
#include <vcl/print.hxx>
#include <vcl/svids.hrc>
#include <comphelper/processfactory.hxx>
@ -1280,6 +1282,48 @@ int Printer::GetPaperInfoCount() const
// -----------------------------------------------------------------------
rtl::OUString Printer::GetPaperName( Paper ePaper )
{
ImplSVData* pSVData = ImplGetSVData();
if( ! pSVData->mpPaperNames )
{
pSVData->mpPaperNames = new std::hash_map< int, rtl::OUString >();
if( ImplGetResMgr() )
{
ResStringArray aPaperStrings( VclResId( RID_STR_PAPERNAMES ) );
static const int PaperIndex[] =
{
PAPER_A0, PAPER_A1, PAPER_A2, PAPER_A3, PAPER_A4, PAPER_A5,
PAPER_B4_ISO, PAPER_B5_ISO, PAPER_LETTER, PAPER_LEGAL, PAPER_TABLOID,
PAPER_USER, PAPER_B6_ISO, PAPER_ENV_C4, PAPER_ENV_C5, PAPER_ENV_C6, PAPER_ENV_C65,
PAPER_ENV_DL, PAPER_SLIDE_DIA, PAPER_SCREEN, PAPER_C, PAPER_D, PAPER_E,
PAPER_EXECUTIVE, PAPER_FANFOLD_LEGAL_DE, PAPER_ENV_MONARCH, PAPER_ENV_PERSONAL,
PAPER_ENV_9, PAPER_ENV_10, PAPER_ENV_11, PAPER_ENV_12, PAPER_KAI16,
PAPER_KAI32, PAPER_KAI32BIG, PAPER_B4_JIS, PAPER_B5_JIS, PAPER_B6_JIS
};
OSL_ENSURE( sal_uInt32(sizeof(PaperIndex)/sizeof(PaperIndex[0])) == aPaperStrings.Count(), "localized paper name count wrong" );
for( int i = 0; i < int(sizeof(PaperIndex)/sizeof(PaperIndex[0])); i++ )
(*pSVData->mpPaperNames)[PaperIndex[i]] = aPaperStrings.GetString(i);
}
}
std::hash_map<int,rtl::OUString>::const_iterator it = pSVData->mpPaperNames->find( (int)ePaper );
return (it != pSVData->mpPaperNames->end()) ? it->second : rtl::OUString();
}
// -----------------------------------------------------------------------
rtl::OUString Printer::GetPaperName( bool i_bPaperUser ) const
{
Size aPageSize = PixelToLogic( GetPaperSizePixel(), MAP_100TH_MM );
Paper ePaper = ImplGetPaperFormat( aPageSize.Width(), aPageSize.Height() );
if( ePaper == PAPER_USER )
ePaper = ImplGetPaperFormat( aPageSize.Height(), aPageSize.Width() );
return (ePaper != PAPER_USER || i_bPaperUser ) ? GetPaperName( ePaper ) : rtl::OUString();
}
// -----------------------------------------------------------------------
const PaperInfo& Printer::GetPaperInfo( int nPaper ) const
{
if( ! mpInfoPrinter )

View file

@ -499,3 +499,48 @@ StringArray SV_PRINT_NATIVE_STRINGS
< "Print selection only"; >;
};
};
StringArray RID_STR_PAPERNAMES
{
ItemList [en-US] =
{
< "A0"; >;
< "A1"; >;
< "A2"; >;
< "A3"; >;
< "A4"; >;
< "A5"; >;
< "B4 (ISO)"; >;
< "B5 (ISO)"; >;
< "Letter"; >;
< "Legal"; >;
< "Tabloid"; >;
< "User Defined"; >;
< "B6 (ISO)"; >;
< "C4 Envelope"; >;
< "C5 Envelope"; >;
< "C6 Envelope"; >;
< "C6/5 Envelope"; >;
< "DL Envelope"; >;
< "Dia Slide"; >;
< "Screen"; >;
< "C"; >;
< "D"; >;
< "E"; >;
< "Executive"; >;
< "Long Bond"; >;
< "#8 (Monarch) Envelope"; >;
< "#6 3/4 (Personal) Envelope"; >;
< "#9 Envelope"; >;
< "#10 Envelope"; >;
< "#11 Envelope"; >;
< "#12 Envelope"; >;
< "16 Kai"; >;
< "32 Kai"; >;
< "Big 32 Kai"; >;
< "B4 (JIS)"; >;
< "B5 (JIS)"; >;
< "B6 (JIS)"; >;
};
};

View file

@ -310,6 +310,7 @@ void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt )
void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview,
const Size& i_rOrigSize,
const rtl::OUString& i_rPaperName,
const rtl::OUString& i_rReplacement,
sal_Int32 i_nDPIX,
sal_Int32 i_nDPIY,
@ -344,6 +345,12 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
String aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
aBuf.append( aNumText );
aBuf.appendAscii( eUnit == MAP_MM ? "mm" : "in" );
if( i_rPaperName.getLength() )
{
aBuf.appendAscii( " (" );
aBuf.append( i_rPaperName );
aBuf.append( sal_Unicode(')') );
}
maHorzDim.SetText( aBuf.makeStringAndClear() );
aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
@ -1891,7 +1898,9 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
}
Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) );
maPreviewWindow.setPreview( aMtf, aCurPageSize, nPages > 0 ? rtl::OUString() : maNoPageStr,
maPreviewWindow.setPreview( aMtf, aCurPageSize,
aPrt->GetPaperName( false ),
nPages > 0 ? rtl::OUString() : maNoPageStr,
aPrt->ImplGetDPIX(), aPrt->ImplGetDPIY(),
aPrt->GetPrinterOptions().IsConvertToGreyscales()
);