[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/openoffice.org/devel openoffice.org-1.9.121.rh127576.gnomeprintui.patch, NONE, 1.1 openoffice.org.spec, 1.356, 1.357



Author: caolanm

Update of /cvs/dist/rpms/openoffice.org/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv23724

Modified Files:
	openoffice.org.spec 
Added Files:
	openoffice.org-1.9.121.rh127576.gnomeprintui.patch 
Log Message:
libgnomeprintui

openoffice.org-1.9.121.rh127576.gnomeprintui.patch:
 inc/print.hxx                       |    0 
 psprint/source/printer/cupsmgr.cxx  |    7 
 source/dialogs/makefile.mk          |    0 
 source/dialogs/printdlg.cxx         |    0 
 source/gdi/jobset.cxx               |    0 
 source/printer/cupsmgr.cxx          |    0 
 svtools/source/dialogs/makefile.mk  |    4 
 svtools/source/dialogs/printdlg.cxx |  445 +++++++++++++++++++++++++++++++++++-
 svtools/util/makefile.mk            |    9 
 util/makefile.mk                    |    0 
 vcl/inc/print.hxx                   |    1 
 vcl/source/gdi/jobset.cxx           |  194 +++++++++++++++
 12 files changed, 657 insertions(+), 3 deletions(-)

--- NEW FILE openoffice.org-1.9.121.rh127576.gnomeprintui.patch ---
Index: source/printer/cupsmgr.cxx
===================================================================
RCS file: /cvs/gsl/psprint/source/printer/cupsmgr.cxx,v
retrieving revision 1.12
diff -u -p -u -r1.12 cupsmgr.cxx
--- openoffice.org.orig/psprint/source/printer/cupsmgr.cxx	6 Jun 2005 16:07:42 -0000	1.12
+++ openoffice.org/psprint/source/printer/cupsmgr.cxx	25 Jul 2005 15:02:37 -0000
@@ -475,9 +487,10 @@ void CUPSManager::initialize()
 
     // clear old stuff
     m_aCUPSDestMap.clear();
-
+#if 0
     if( ! (m_nDests && m_pDests ) )
         return;
+#endif
 
     rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
     int nPrinter = m_nDests;
@@ -550,6 +563,10 @@ void CUPSManager::initialize()
 
     m_pCUPSWrapper->cupsSetPasswordCB( setPasswordCallback );
 #endif // ENABLE_CUPS
+
+	addPrinter(rtl::OUString::createFromAscii("GENERIC"),
+		rtl::OUString::createFromAscii("SGENPRT"));
+
 }
 
 #ifdef ENABLE_CUPS
Index: source/dialogs/makefile.mk
===================================================================
RCS file: /cvs/util/svtools/source/dialogs/makefile.mk,v
retrieving revision 1.13
diff -u -p -u -r1.13 makefile.mk
--- openoffice.org.orig/svtools/source/dialogs/makefile.mk	27 Apr 2005 09:45:56 -0000	1.13
+++ openoffice.org/svtools/source/dialogs/makefile.mk	25 Jul 2005 14:24:16 -0000
@@ -70,6 +70,10 @@ TARGET=dialogs
 .INCLUDE :	settings.mk
 .INCLUDE :  $(PRJ)$/util$/svt.pmk
 
+
+PKGCONFIG_MODULES=libgnomeprintui-2.2
+.INCLUDE: pkg_config.mk
+
 # --- Files --------------------------------------------------------
 
 SRS1NAME=$(TARGET)
Index: source/dialogs/printdlg.cxx
===================================================================
RCS file: /cvs/util/svtools/source/dialogs/printdlg.cxx,v
retrieving revision 1.20
diff -u -p -u -r1.20 printdlg.cxx
--- openoffice.org.orig/svtools/source/dialogs/printdlg.cxx	3 Feb 2004 17:02:46 -0000	1.20
+++ openoffice.org/svtools/source/dialogs/printdlg.cxx	25 Jul 2005 14:24:19 -0000
@@ -109,6 +109,33 @@
 #include <comphelper/processfactory.hxx>
 #endif
 
+#if 1
+#include <libgnomeprintui/gnome-print-dialog.h>
+#include <libgnomeprintui/gnome-print-job-preview.h>
+#include <svtools/stritem.hxx> 
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <osl/file.hxx>
+#include <osl/process.h>
+#define WE_ARE_LIBGNOMEPRINT_INTERNALS
+#include <libgnomeprint/private/gpa-utils.h>
+G_END_DECLS
+#include <libgnomeprint/gnome-print-config.h>
+#include <libgnomeprint/gnome-print.h>
+#include <libgnomeprint/private/gpa-printer.h>
+#include <libgnomeprint/private/gpa-key.h>
+#include <libgnomeprint/private/gpa-node.h>
+#include <libgnomeprint/private/gpa-state.h>
+#include <libgnomeprint/private/gpa-root.h>
+#include <libgnomeprint/private/gnome-print-config-private.h>
+#include <libgnomeprint/private/gpa-option.h>
+
+#include <psprint/printerinfomanager.hxx>
+
+using namespace osl;
+#endif
+
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
 using namespace com::sun::star::ui::dialogs;
@@ -632,6 +661,118 @@ void PrintDialog::DataChanged( const Dat
 
 // -----------------------------------------------------------------------
 
+#if 1
+inline const guchar* O2G(const OString &rStr)
+{
+       return (const guchar*)(rStr.getStr());
+}
+
+inline String G2S(const guchar *pStr)
+{
+       return String(ByteString((sal_Char*)pStr), RTL_TEXTENCODING_UTF8);
+}
+
+inline rtl::OUString G2OU(const guchar *pStr)
+{
+       return rtl::OUString((const sal_Char *)pStr,
+           strlen((const sal_Char*)(pStr)), RTL_TEXTENCODING_UTF8);
+}
+
+rtl::OUString PathToURL(const rtl::OUString &rPath)
+{
+	rtl::OUString sWorkDir;
+	osl_getProcessWorkingDir(&sWorkDir.pData);
+
+	rtl::OUString sFileURL; 
+	FileBase::getFileURLFromSystemPath(rPath, sFileURL);
+	rtl::OUString sAbsFileURL;
+	FileBase::getAbsoluteFileURL(sWorkDir, sFileURL, sAbsFileURL);
+	return sAbsFileURL;
+}
+
+inline const char* G2C(const guchar *pStr)
+{
+       return (const char*)(pStr);
+}
+
+inline const guchar* C2G(const char *pStr)
+{
+       return (const guchar*)(pStr);
+}
+
+static void
+scrubber(GPANode *pRoot, const char *pKey, const char *pOption, bool bMatch)
+{
+	if (GPANode *pFeed = gpa_node_lookup(pRoot, C2G(pKey)))
+	{
+		GPANode *option = pFeed;
+		if (GPA_IS_KEY(pFeed))
+		{
+			GPAKey *key = GPA_KEY(pFeed);
+			option = key->option;
+		}
+		GPANode* child = gpa_node_get_child(option, NULL);
+		while (child) 
+		{
+			char *name = gpa_option_get_name(child);
+			GPANode *nextchild = gpa_node_get_child (option, child);
+			bool bFound = (strcmp(G2C(gpa_node_id(child)), pOption) == 0);
+			if (bFound == bMatch)
+				gpa_node_detach_unref(child);
+			child = nextchild;
+		}
+	}
+}
+
+static void
+scrub_from_key(GPANode *pRoot, const char *pKey, const char *pOption)
+{
+	scrubber(pRoot, pKey, pOption, true);
+}
+
+static void
+scrub_reduce_key(GPANode *pRoot, const char *pKey, const char *pOption)
+{
+	scrubber(pRoot, pKey, pOption, false);
+}
+
+static void
+scrub_global_config (GPANode *pRoot)
+{
+	scrub_from_key(pRoot, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R180");
+	scrub_from_key(pRoot, GNOME_PRINT_KEY_PAGE_ORIENTATION, "R270");
+	scrub_reduce_key(pRoot, GNOME_PRINT_KEY_LAYOUT, "Plain");
+}
+
+static void
+scrub_printer(GPANode *pRoot)
+{
+	scrub_from_key(pRoot, "Model.Options.Output.Media.PhysicalSize", "Custom");
+	scrub_reduce_key(pRoot, "Model.Options.Output.Media.PhysicalOrientation", "R0");
+}
+
+static void
+gpa_printer_selector_printer_added_cb (GPANode *parent, GPANode *child,
+                                       void *ps)
+{
+	GPAPrinter *printer = GPA_PRINTER(child);
+	scrub_printer(child);
+}
+
+static
+rtl::OUString get_option(GnomePrintConfig *pConfig, const char *pKey)
+{
+	rtl::OUString sString;
+	if (guchar *pString = gnome_print_config_get(pConfig, C2G(pKey)))
+	{
+		sString = G2OU(pString);
+		g_free(pString);
+	}
+	return sString;
+}
+
+#endif
+
 short PrintDialog::Execute()
 {
 	if ( !mpPrinter || mpPrinter->IsPrinting() || mpPrinter->IsJobActive() )
@@ -647,6 +796,310 @@ short PrintDialog::Execute()
 	ImplInitControls();
 	ImplModifyControlHdl( NULL );
 
+#if 1
+	static GPAList *pKnownPrinters;
+	if (!pKnownPrinters)
+	{
+		if (!gpa_initialized())
+			gpa_init();
+		pKnownPrinters = gpa_get_printers();
+
+        	g_signal_connect_object (GPA_NODE(pKnownPrinters), "child-added",
+                                 G_CALLBACK (gpa_printer_selector_printer_added_cb),
+                                 NULL, GConnectFlags(0));
+
+   		GPANode* child = gpa_node_get_child (GPA_NODE(pKnownPrinters), NULL);
+        	while (child) {
+			GPAPrinter *printer = GPA_PRINTER(child);
+			gpa_printer_selector_printer_added_cb(GPA_NODE(pKnownPrinters), 
+				child, 0);
+                	child = gpa_node_get_child (GPA_NODE(pKnownPrinters), child);
+        	}
+	}
+
+	Printer* pPrinter = mpPrinter;
+
+	DisableHelp();
+
+	GnomePrintJob *pJob = gnome_print_job_new(NULL);
+
+	GnomePrintConfig *pConfig = gnome_print_job_get_config(pJob);
+
+	OString sSelected(
+		rtl::OUStringToOString(pPrinter->GetName(), RTL_TEXTENCODING_UTF8));
+	gnome_print_config_set (pConfig, C2G("Printer"), O2G(sSelected));
+
+	scrub_global_config(gnome_print_config_get_node(pConfig));
+
+	GtkWidget *pDialog = (GtkWidget*)g_object_new (GNOME_TYPE_PRINT_DIALOG,
+		"print_config", pConfig, NULL);
+
+	OString sPrint(OUStringToOString(GetText(), RTL_TEXTENCODING_UTF8));
+	gnome_print_dialog_construct (GNOME_PRINT_DIALOG (pDialog), O2G(sPrint),
+		GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES);
+
+	gint nSelectionFlags = 0;
+	if (mbAll)
+		nSelectionFlags |= GNOME_PRINT_RANGE_ALL;
+	if (mbRange)
+		nSelectionFlags |= GNOME_PRINT_RANGE_RANGE;
+	if (mbSelection)
+		nSelectionFlags |= GNOME_PRINT_RANGE_SELECTION;
+	else
+		nSelectionFlags |= GNOME_PRINT_RANGE_SELECTION_UNSENSITIVE;
+
+	OString sPages(OUStringToOString(maRbtPages.GetText(), 
+		RTL_TEXTENCODING_UTF8));
+	gnome_print_dialog_construct_range_page ( GNOME_PRINT_DIALOG (pDialog),
+		nSelectionFlags, mnFirstPage, mnLastPage, 
+		C2G("A"), O2G(sPages));
+
+	gnome_print_dialog_set_copies(GNOME_PRINT_DIALOG (pDialog), 
+		GetCopyCount(), IsCollateEnabled());
+
+	rtl::OString aOptions(OUStringToOString(maBtnOptions.GetText(), 
+		RTL_TEXTENCODING_UTF8));
+	aOptions = aOptions.replace('~','_');
+
+	//remove Print Preview, figure out which ones have it and sensitive/insensitive
+  	GList *pChildren =
+        	gtk_container_get_children(GTK_CONTAINER(GTK_DIALOG(pDialog)->action_area));
+	gtk_button_set_label(GTK_BUTTON(pChildren->data), aOptions.getStr());
+    	g_list_free( pChildren );
+
+	gint nStatus = 0;
+	bool bPrintToFile(false);
+	gboolean bDuplex(false);
+	gboolean bTumble(false);
+	gboolean bHasDuplex(false);
+	gboolean bHasTumble(false);
+	rtl::OUString sPageSize;
+	rtl::OUString sPaperSource;
+	rtl::OUString sOrientation;
+	rtl::OUString sSystemPath;
+	rtl::OUString sWhenToPrint;
+	rtl::OUString sCommand;
+	short nRet = FALSE;
+
+	while(1)
+	{
+		nStatus = gtk_dialog_run( GTK_DIALOG( pDialog ) );
+	
+		if (nStatus == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW)
+			ClickOptionsHdl();
+		else if (nStatus == GNOME_PRINT_DIALOG_RESPONSE_PRINT)
+		{
+			gtk_widget_hide( pDialog );
+			OUString sNewPrinterName(get_option(pConfig, "Printer"));
+	
+			bool bPrintToPDF = sNewPrinterName.equalsAscii("PDF");
+	
+			bool bPrintToPipe = false;
+	
+			if (!bPrintToPDF)
+			{
+				guchar *pType = gnome_print_config_get(pConfig,
+					C2G("Settings.Transport.Backend"));
+				bPrintToFile = strcmp(G2C(pType), "file") ? false : true;
+//				bPrintToPipe = strcmp(G2C(pType), "custom") ? false : true;
+				g_free (pType);
+			}
+	
+			OUString sAbsFileURL;
+			sCommand = get_option(pConfig, "Settings.Transport.Backend.Command");
+			if (!sCommand.getLength())
+				sCommand = rtl::OUString::createFromAscii("lpr");
+			if (bPrintToPDF || bPrintToFile)
+			{
+				sAbsFileURL = PathToURL(
+					get_option(pConfig, GNOME_PRINT_KEY_OUTPUT_FILENAME));
+			}
+#if 0
+			else if (bPrintToPipe)
+				sCommand = get_option(pConfig, "Settings.Transport.Backend.Command");
+#endif
+	
+			bHasDuplex = gnome_print_config_get_boolean(pConfig, 
+				C2G(GNOME_PRINT_KEY_DUPLEX), &bDuplex);
+	
+			bHasTumble = gnome_print_config_get_boolean(pConfig, 
+				C2G(GNOME_PRINT_KEY_TUMBLE), &bTumble);
+	
+			sPageSize = get_option(pConfig, GNOME_PRINT_KEY_PAPER_SIZE);
+			sOrientation = get_option(pConfig, GNOME_PRINT_KEY_PAGE_ORIENTATION);
+			sPaperSource = get_option(pConfig, GNOME_PRINT_KEY_PAPER_SOURCE);
+			sWhenToPrint = get_option(pConfig, GNOME_PRINT_KEY_HOLD);
+	
+			gdouble nWidth;
+			const GnomePrintUnit *unit;
+			gnome_print_config_get_length(pConfig, 
+				C2G(GNOME_PRINT_KEY_PAPER_WIDTH), &nWidth, &unit);
+			gnome_print_convert_distance (&nWidth, unit, GNOME_PRINT_PS_UNIT);
+	
+			gdouble nHeight;
+			gnome_print_config_get_length(pConfig, 
+				C2G(GNOME_PRINT_KEY_PAPER_HEIGHT), &nHeight, &unit);
+			gnome_print_convert_distance (&nHeight, unit, GNOME_PRINT_PS_UNIT);
+	
+			if (bPrintToPDF)
+			{
+				SfxViewFrame* pFrm = SfxViewFrame::Current();
+				SfxDispatcher* pDisp = pFrm->GetDispatcher();
+				SfxStringItem aFileName(SID_FILE_NAME, sAbsFileURL);
+				pDisp->Execute(SID_EXPORTDOCASPDF, 
+					SFX_CALLMODE_SYNCHRON, &aFileName, 0L );
+				nRet = FALSE;
+			}
+			else
+			{
+				nRet = TRUE;
+				OUString sOldPrinterName(pPrinter->GetName());
+				if (sNewPrinterName != sOldPrinterName)
+				{
+					USHORT nCount = Printer::GetQueueCount();
+					USHORT i = 0;
+					for (i = 0; i < nCount; ++i)
+					{
+						const QueueInfo& rInfo = Printer::GetQueueInfo(i, false);
+						if (OUString(rInfo.GetPrinterName()) == sNewPrinterName)
+						{
+							Printer aTempPrinter(rInfo);
+							pPrinter->SetPrinterProps(&aTempPrinter);
+
+							break;
+						}
+					}
+					if (i == nCount)
+					{
+						const QueueInfo& rInfo = Printer::GetQueueInfo(0, false);
+						Printer aTempPrinter(rInfo);
+						pPrinter->SetPrinterProps(&aTempPrinter);
+					}
+				}
+			}
+	
+			if (bPrintToFile)
+				FileBase::getSystemPathFromFileURL(sAbsFileURL, sSystemPath);
+	
+			gint nCopyCount, bCollateCheck;
+			gnome_print_dialog_get_copies(GNOME_PRINT_DIALOG(pDialog), 
+				&nCopyCount, &bCollateCheck);
+			SetCopyCount(nCopyCount);
+			EnableCollate(bCollateCheck);
+	
+			int nRange = gnome_print_dialog_get_range(
+				GNOME_PRINT_DIALOG(pDialog));
+	
+			switch (nRange)
+			{
+				case GNOME_PRINT_RANGE_ALL:
+					meCheckRange = PRINTDIALOG_ALL;
+					break;
+				case GNOME_PRINT_RANGE_RANGE:
+				{
+					int start, end;
+  	              		meCheckRange = PRINTDIALOG_RANGE;
+					gnome_print_dialog_get_range_page(
+						GNOME_PRINT_DIALOG(pDialog), 
+						&start, &end);
+  	              		maRangeText = 
+						String::CreateFromInt32(start) + 
+						String::CreateFromAscii( "-" ) +
+						String::CreateFromInt32(end);
+					break;
+				}
+				case GNOME_PRINT_RANGE_SELECTION:
+					meCheckRange = PRINTDIALOG_SELECTION;
+					break;
+				default:
+					fprintf(stderr, "what selection ?\n");
+					break;
+			}
+		break;
+		}
+		else
+		{
+			gtk_widget_hide( pDialog );
+			break;
+		}
+	}
+
+	gnome_print_config_dump(pConfig);
+	gtk_widget_destroy( pDialog );
+	g_object_unref (pConfig);
+	g_object_unref (pJob);
+
+	if( nRet == TRUE )
+	{
+		if (bPrintToFile)
+			pPrinter->SetPrintFile(sSystemPath);
+		pPrinter->EnablePrintFile(bPrintToFile);
+
+		if (bHasDuplex)
+		{
+			if (!bDuplex)
+			{
+				pPrinter->SetJobKey(
+					String::CreateFromAscii("Duplex"), 
+					String::CreateFromAscii("None"));
+			}
+			else
+			{
+				if (bHasTumble && bTumble)
+				{
+					pPrinter->SetJobKey(
+						String::CreateFromAscii("Duplex"), 
+						String::CreateFromAscii("DuplexTumble"));
+				}
+				else
+				{
+					pPrinter->SetJobKey(
+						String::CreateFromAscii("Duplex"), 
+						String::CreateFromAscii("DuplexNoTumble"));
+
+				}
+			}
+		}
+
+		pPrinter->SetJobKey(
+			String::CreateFromAscii("PageSize"), 
+			sPageSize);
+
+		Orientation eOrient = ORIENTATION_PORTRAIT;
+		if (
+			sOrientation == G2OU(C2G("R90")) ||
+			sOrientation == G2OU(C2G("R270"))
+		   )
+		{
+			eOrient = ORIENTATION_LANDSCAPE;
+		}
+		pPrinter->SetOrientation(eOrient);
+
+		if (sPaperSource.getLength())
+		{
+			pPrinter->SetJobKey(
+				String::CreateFromAscii("InputSlot"), 
+				sPaperSource);
+		}
+
+		if (sWhenToPrint.getLength())
+		{
+			pPrinter->SetJobKey(
+				String::CreateFromAscii("job-hold-until"), 
+				sWhenToPrint);
+		}
+
+		if (sCommand.getLength())
+		{
+			OUString sOldPrinterName(pPrinter->GetName());
+			psp::PrinterInfoManager& rMgr = psp::PrinterInfoManager::get();
+			psp::PrinterInfo aInfo(rMgr.getPrinterInfo(pPrinter->GetName()));
+			aInfo.m_aCommand = sCommand;
+			rMgr.changePrinterInfo(pPrinter->GetName(), aInfo);
+		}
+
+	}
+#else
 	// Dialog starten
 	short nRet = ModalDialog::Execute();
 
@@ -657,6 +1128,7 @@ short PrintDialog::Execute()
 			mpPrinter->SetPrinterProps( TEMPPRINTER() );
 		ImplFillDialogData();
 	}
+#endif
 
 	maStatusTimer.Stop();
 
@@ -670,4 +1142,3 @@ void PrintDialog::DisableHelp()
 	mpPrinterImpl->m_bHelpDisabled = sal_True;
 	maBtnHelp.Disable();
 }
-
Index: util/makefile.mk
===================================================================
RCS file: /cvs/util/svtools/util/makefile.mk,v
retrieving revision 1.53
diff -u -p -u -r1.53 makefile.mk
--- openoffice.org.orig/svtools/util/makefile.mk	7 Jul 2005 13:11:33 -0000	1.53
+++ openoffice.org/svtools/util/makefile.mk	25 Jul 2005 14:24:43 -0000
@@ -71,6 +71,9 @@ GEN_HID=TRUE
 GEN_HID_OTHER=TRUE
 ENABLE_EXCEPTIONS=TRUE
 
+PKGCONFIG_MODULES=libgnomeprintui-2.2
+.INCLUDE: pkg_config.mk
+
 # --- Settings -----------------------------------------------------
 
 .INCLUDE :	settings.mk
@@ -184,8 +187,12 @@ SHL1STDLIBS+= \
 		$(CPPULIB)			\
 		$(VOSLIB)			\
 		$(SALLIB)			\
-		$(ICUUCLIB)		\
+		$(ICUUCLIB)			\
+		$(SFXLIB)			\
+		-lpsp$(VERSION)$(DLLPOSTFIX)\
 		$(JVMFWKLIB)
+
+SHL1STDLIBS+=$(PKGCONFIG_LIBS)
 
 .IF "$(OS)"=="MACOSX"
 # static libraries go at end
Index: inc/print.hxx
===================================================================
RCS file: /cvs/gsl/vcl/inc/print.hxx,v
retrieving revision 1.21
diff -u -p -u -r1.21 print.hxx
--- openoffice.org.orig/vcl/inc/print.hxx	31 Jan 2005 09:15:32 -0000	1.21
+++ openoffice.org/vcl/inc/print.hxx	25 Jul 2005 14:22:25 -0000
@@ -382,6 +382,7 @@ public:
 	const JobSetup& 			GetJobSetup() const { return maJobSetup; }
 	String						GetJobValue( const String& rKey ) const { return maJobSetup.GetValue( rKey ); }
 	void						SetJobValue( const String& rKey, const String& rValue ) { maJobSetup.SetValue( rKey, rValue ); }
+	void						SetJobKey( const String& rKey, const String& rValue ) { maJobSetup.SetKey( rKey, rValue ); }
 
 	BOOL						Setup( Window* pWindow = NULL );
 	BOOL						SetPrinterProps( const Printer* pPrinter );
Index: source/gdi/jobset.cxx
===================================================================
RCS file: /cvs/gsl/vcl/source/gdi/jobset.cxx,v
retrieving revision 1.8
diff -u -p -u -r1.8 jobset.cxx
--- openoffice.org.orig/vcl/source/gdi/jobset.cxx	6 Jan 2004 13:46:09 -0000	1.8
+++ openoffice.org/vcl/source/gdi/jobset.cxx	25 Jul 2005 14:22:37 -0000
@@ -76,6 +76,7 @@
 #include <jobset.h>
 #endif
 
+#include <psprint/printerinfomanager.hxx>
 // =======================================================================
 
 DBG_NAME( JobSetup );
@@ -267,6 +268,199 @@ void JobSetup::SetValue( const String& r
 		mpData = new ImplJobSetup();
 
 	mpData->maValueMap[ rKey ] = rValue;
+}
+
+inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); }
+void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, psp::JobData& rData );
+
+static struct
+{
+	int			width;
+	int			height;
+	const char*	name;
+	int			namelength;
+	Paper		paper;
+} aPaperTab[] =
+{
+	{ 29700, 42000,	"A3",			2,	PAPER_A3		},
+	{ 21000, 29700,	"A4",			2,	PAPER_A4		},
+	{ 14800, 21000,	"A5",			2,	PAPER_A5		},
+	{ 25000, 35300,	"B4",			2,	PAPER_B4		},
+	{ 17600, 25000,	"B5",			2,	PAPER_B5		},
+	{ 21600, 27900,	"Letter",		6,	PAPER_LETTER	},
+	{ 21600, 35600,	"Legal",		5,	PAPER_LEGAL		},
+	{ 27900, 43100,	"Tabloid",		7,	PAPER_TABLOID	},
+	{ 0, 0,	  		"USER",			4,	PAPER_USER		}
+};
+
+static Paper getPaperType( const String& rPaperName )
+{
+	ByteString aPaper( rPaperName, RTL_TEXTENCODING_ISO_8859_1 );
+	for( unsigned int i = 0; i < sizeof( aPaperTab )/sizeof( aPaperTab[0] ); i++ )
+	{
+		if( ! strcmp( aPaper.GetBuffer(), aPaperTab[i].name ) )
+			return aPaperTab[i].paper;
+	}
+	return PAPER_USER;
+}
+
+
+
+void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, psp::JobData& rData )
+{
+	using namespace psp;
+
+	pJobSetup->meOrientation	= (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+
+
+	// copy page size
+	String aPaper;
+	int width, height;
+
+	rData.m_aContext.getPageSize( aPaper, width, height );
+	pJobSetup->mePaperFormat	= getPaperType( aPaper );
+	pJobSetup->mnPaperWidth		= 0;
+	pJobSetup->mnPaperHeight	= 0;
+	if( pJobSetup->mePaperFormat == PAPER_USER )
+	{
+		// transform to 100dth mm
+		width				= PtTo10Mu( width );
+		height				= PtTo10Mu( height );
+
+        if( rData.m_eOrientation == psp::orientation::Portrait )
+        {
+            pJobSetup->mnPaperWidth	= width;
+            pJobSetup->mnPaperHeight= height;
+        }
+        else
+        {
+            pJobSetup->mnPaperWidth	= height;
+            pJobSetup->mnPaperHeight= width;
+        }
+	}
+
+	// copy input slot
+	const PPDKey* pKey = NULL;
+	const PPDValue* pValue = NULL;
+
+    pJobSetup->mnPaperBin = 0xffff;
+	pKey						= rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
+    if( pKey )
+        pValue					= rData.m_aContext.getValue( pKey );
+    if( pKey && pValue )
+    {
+        for( pJobSetup->mnPaperBin = 0;
+             pValue != pKey->getValue( pJobSetup->mnPaperBin ) &&
+                 pJobSetup->mnPaperBin < pKey->countValues();
+             pJobSetup->mnPaperBin++ )
+            ;
+        if( pJobSetup->mnPaperBin >= pKey->countValues() || pValue == pKey->getDefaultValue() )
+            pJobSetup->mnPaperBin = 0xffff;
+    }
+	
+
+	// copy the whole context
+	if( pJobSetup->mpDriverData )
+		rtl_freeMemory( pJobSetup->mpDriverData );
+
+	int nBytes;
+	void* pBuffer = NULL;
+	if( rData.getStreamBuffer( pBuffer, nBytes ) )
+	{
+		pJobSetup->mnDriverDataLen = nBytes;
+		pJobSetup->mpDriverData = (BYTE*)pBuffer;
+	}
+	else
+	{
+		pJobSetup->mnDriverDataLen = 0;
+		pJobSetup->mpDriverData = NULL;
+	}
+}
+
+void JobSetup::SetKey( const String& rKey, const String& rValue )
+{
+	if( ! mpData )
+		mpData = new ImplJobSetup();
+
+	using namespace psp;
+
+	PrinterInfoManager& rManager = PrinterInfoManager::get();
+	PrinterInfo aInfo(rManager.getPrinterInfo(mpData->maPrinterName));
+	if (mpData->mpDriverData )
+	{
+		JobData::constructFromStreamBuffer(mpData->mpDriverData, 
+		mpData->mnDriverDataLen, aInfo);
+	}
+	if (aInfo.m_pParser)
+	{
+		if (const PPDKey* pKey = aInfo.m_pParser->getKey(rKey))
+		{
+			bool bFound = false;
+			for (int i = 0; i < pKey->countValues(); ++i)
+			{
+               	const PPDValue *pValue = pKey->getValue(i);
+               	if (rValue == pValue->m_aOption)
+				{
+					aInfo.m_aContext.setValue(pKey, pValue);
+					bFound = true;
+					break;
+				}
+			}
+			if (!bFound && rKey == String::CreateFromAscii("PageSize"))
+			{
+				String aString(rValue);
+				if (aString == String::CreateFromAscii("USLetter"))
+					aString = String::CreateFromAscii("Letter");
+				else if (aString == String::CreateFromAscii("USLegal"))
+					aString = String::CreateFromAscii("Legal");
+				for (int i = 0; i < pKey->countValues(); ++i)
+				{
+					const PPDValue *pValue = pKey->getValue(i);
+					if (aString == pValue->m_aOption)
+					{
+						aInfo.m_aContext.setValue(pKey, pValue);
+						bFound = true;
+						break;
+					}
+				}
+			}
+			if (!bFound)	
+				fprintf(stderr, "Unknown value\n");
+		}
+		else
+		{
+			fprintf(stderr, "Unknown key\n");
+		}
+	}
+
+    String aPaper;
+    int nWidth, nHeight;
+    aInfo.m_aContext.getPageSize (aPaper, nWidth, nHeight);
+
+	copyJobDataToJobSetup( mpData, aInfo );
+
+#if 0
+	// copy the whole context
+	if (mpData->mpDriverData)
+		rtl_freeMemory( mpData->mpDriverData );
+
+	int nBytes;
+	void* pBuffer = NULL;
+	if( aInfo.getStreamBuffer( pBuffer, nBytes ) )
+	{
+		mpData->mnDriverDataLen = nBytes;
+	        mpData->mpDriverData = (BYTE*)pBuffer;
+	}
+	else
+	{
+	        mpData->mnDriverDataLen = 0;
+	        mpData->mpDriverData = NULL;
+	}
+
+
+	mpData->mnDriverDataLen = nBytes;
+        mpData->mpDriverData = (BYTE*)pBuffer;
+#endif
 }
 
 // -----------------------------------------------------------------------


Index: openoffice.org.spec
===================================================================
RCS file: /cvs/dist/rpms/openoffice.org/devel/openoffice.org.spec,v
retrieving revision 1.356
retrieving revision 1.357
diff -u -r1.356 -r1.357
--- openoffice.org.spec	25 Jul 2005 16:45:27 -0000	1.356
+++ openoffice.org.spec	25 Jul 2005 19:52:24 -0000	1.357
@@ -162,6 +162,7 @@
 Patch59: openoffice.org-1.9.118.forwarddecl.psprint.patch
 Patch60: openoffice.org-1.9.118.rhXXXXX.envcflags.solenv.patch
 Patch61: openoffice.org-1.9.120.rh158977.execshield.bridges.patch
+Patch62: openoffice.org-1.9.121.rh127576.gnomeprintui.patch
 
 %define instdir %{_libdir}/openoffice.org2.0
 
@@ -219,6 +220,15 @@
 external to %{name} and within the internal %{name} scripting module to be
 written in python
 
+%package base
+Summary: database frontend for %{name}
+Group: Development/Libraries
+Requires: %{name}-core = %{epoch}:%{version}-%{release}
+
+%description base
+Gui database frontend for %{name}. Allows creation and management of databases
+through a GUI.
+
 %package writer
 Summary: writer module for %{name}
 Group: Applications/Productivity
@@ -807,6 +817,9 @@
 %patch59 -p1 -b .forwarddecl.psprint.patch
 # %patch60 -p1 -b .rhXXXXX.envcflags.solenv.patch
 %patch61 -p1 -b .rh158977.execshield.bridges.patch
+%if %{build_fc5}
+%patch62 -p1 -b .rh127576.gnomeprintui.patch
+%endif
 
 %if %{includeexternals}
 #start ludicrous workaround
@@ -2581,7 +2594,26 @@
 %{_datadir}/icons
 %dir %{_datadir}/mime-info
 %{_datadir}/mime-info/*
-#datebase files, create a seperate package ?
+
+%post core
+update-desktop-database -q %{_datadir}/applications
+for theme in hicolor; do
+  touch --no-create %{_datadir}/icons/$theme
+  if [ -x /usr/bin/gtk-update-icon-cache ]; then
+    gtk-update-icon-cache -q %{_datadir}/icons/$theme
+  fi
+done
+
+%postun core
+update-desktop-database -q %{_datadir}/applications
+for theme in hicolor; do
+  touch --no-create %{_datadir}/icons/$theme
+  if [ -x /usr/bin/gtk-update-icon-cache ]; then
+    gtk-update-icon-cache -q %{_datadir}/icons/$theme
+  fi
+done
+
+%files base
 %{instdir}/help/en/sdatabase.*
 %{instdir}/program/sbase
 %dir %{instdir}/share/registry
@@ -2600,23 +2632,11 @@
 %dir %{_datadir}/mimelnk/application
 %{_datadir}/mimelnk/application/openoffice.org-1.9-oasis-database.desktop
 
-%post core
+%post base
 update-desktop-database -q %{_datadir}/applications
-for theme in hicolor; do
-  touch --no-create %{_datadir}/icons/$theme
-  if [ -x /usr/bin/gtk-update-icon-cache ]; then
-    gtk-update-icon-cache -q %{_datadir}/icons/$theme
-  fi
-done
 
-%postun core
+%postun base
 update-desktop-database -q %{_datadir}/applications
-for theme in hicolor; do
-  touch --no-create %{_datadir}/icons/$theme
-  if [ -x /usr/bin/gtk-update-icon-cache ]; then
-    gtk-update-icon-cache -q %{_datadir}/icons/$theme
-  fi
-done
 
 %files calc
 %defattr(-,root,root)
@@ -3020,7 +3040,8 @@
 
 %changelog
 * Mon Jul 25 2005 Caolan McNamara <caolanm redhat com> - 1:1.9.121-2
-- ppc problem is likely gcc#17828#
+- rh#127576# add libgnomeprintui 
+- make database front end into pseudo subpackage
 
 * Mon Jul 25 2005 Caolan McNamara <caolanm redhat com> - 1:1.9.121-1
 - next version


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]