summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2011-12-05 15:05:57 +0100
committerDavid Tardon <dtardon@redhat.com>2011-12-05 15:19:42 +0100
commitac9f72d9627f979f1e4bd0490578aba1ede577d4 (patch)
tree85fd0b5409091572594e77b093c9183d328bde94 /vcl
parent62fd44a5e342d97aacc0c2b33c07e3918251676c (diff)
add support for printing selections
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk/gdi/salprn-gtk.cxx65
1 files changed, 52 insertions, 13 deletions
diff --git a/vcl/unx/gtk/gdi/salprn-gtk.cxx b/vcl/unx/gtk/gdi/salprn-gtk.cxx
index 2b34672e0915..fa81cb63ac56 100644
--- a/vcl/unx/gtk/gdi/salprn-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salprn-gtk.cxx
@@ -122,7 +122,7 @@ private:
void impl_initDialog();
void impl_initCustomTab();
- void impl_initPrintRange();
+ void impl_initPrintContent(uno::Sequence<sal_Bool> const& i_rDisabled);
void impl_readFromSettings();
void impl_storeToSettings() const;
@@ -489,7 +489,6 @@ GtkPrintDialog::GtkPrintDialog(vcl::PrinterController& io_rController)
assert(m_pWrapper->supportsPrinting());
impl_initDialog();
impl_initCustomTab();
- impl_initPrintRange();
impl_readFromSettings();
}
@@ -544,6 +543,7 @@ GtkPrintDialog::impl_initCustomTab()
rtl::OUString aText;
rtl::OUString aPropertyName;
uno::Sequence<rtl::OUString> aChoices;
+ uno::Sequence<sal_Bool> aChoicesDisabled;
uno::Sequence<rtl::OUString> aHelpTexts;
sal_Int64 nMinValue = 0, nMaxValue = 0;
sal_Int32 nCurHelpText = 0;
@@ -552,6 +552,7 @@ GtkPrintDialog::impl_initCustomTab()
sal_Bool bUseDependencyRow = sal_False;
sal_Bool bIgnore = sal_False;
GtkWidget* pGroup = NULL;
+ bool bGtkInternal = false;
for (int n = 0; n != aOptProp.getLength(); n++)
{
@@ -566,6 +567,8 @@ GtkPrintDialog::impl_initCustomTab()
rEntry.Value >>= aCtrlType;
else if (rEntry.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Choices")))
rEntry.Value >>= aChoices;
+ else if (rEntry.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ChoicesDisabled")))
+ rEntry.Value >>= aChoicesDisabled;
else if (rEntry.Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Property")))
{
beans::PropertyValue aVal;
@@ -617,6 +620,9 @@ GtkPrintDialog::impl_initCustomTab()
}
}
+ if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("PrintContent")))
+ bGtkInternal = true;
+
if (aCtrlType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Group")) || !pCurParent)
{
pCurTabPage = gtk_vbox_new(FALSE, 12);
@@ -637,6 +643,15 @@ GtkPrintDialog::impl_initCustomTab()
pCurSubGroup = lcl_makeFrame(pCurParent, aText, aHelpTexts, NULL);
gtk_box_pack_start(GTK_BOX(pCurTabPage), pCurSubGroup, FALSE, FALSE, 0);
}
+ // special case: we need to map these to controls of the gtk print dialog
+ else if (bGtkInternal)
+ {
+ if (aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("PrintContent")))
+ {
+ // What to print? And, more importantly, is there a selection?
+ impl_initPrintContent(aChoicesDisabled);
+ }
+ }
else if (bIgnoreSubgroup || bIgnore)
continue;
else
@@ -814,11 +829,24 @@ GtkPrintDialog::impl_initCustomTab()
void
-GtkPrintDialog::impl_initPrintRange()
+GtkPrintDialog::impl_initPrintContent(uno::Sequence<sal_Bool> const& i_rDisabled)
{
- if (!m_pWrapper->supportsPrintSelection())
+ SAL_WARN_IF(i_rDisabled.getLength() != 3, "vcl.gtk", "there is more choices than we expected");
+ if (i_rDisabled.getLength() != 3)
return;
+ GtkPrintUnixDialog* const pDialog(GTK_PRINT_UNIX_DIALOG(m_pDialog));
+
+ // XXX: This is a hack that depends on the number and the ordering of
+ // the controls in the rDisabled sequence (cf. the intialization of
+ // the "PrintContent" UI option in SwPrintUIOptions::SwPrintUIOptions,
+ // sw/source/core/view/printdata.cxx)
+ if (m_pWrapper->supportsPrintSelection() && !i_rDisabled[2])
+ {
+ m_pWrapper->print_unix_dialog_set_support_selection(pDialog, TRUE);
+ m_pWrapper->print_unix_dialog_set_has_selection(pDialog, TRUE);
+ }
+
beans::PropertyValue* const pPrintContent(
m_rController.getValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PrintContent"))));
@@ -826,17 +854,28 @@ GtkPrintDialog::impl_initPrintRange()
{
sal_Int32 nSelectionType(0);
pPrintContent->Value >>= nSelectionType;
- if (nSelectionType == 2)
+ GtkPrintSettings* const pSettings(getSettings());
+ GtkPrintPages ePrintPages(GTK_PRINT_PAGES_ALL);
+ switch (nSelectionType)
{
- GtkPrintUnixDialog* const pDialog(GTK_PRINT_UNIX_DIALOG(m_pDialog));
- m_pWrapper->print_unix_dialog_set_support_selection(pDialog, TRUE);
- m_pWrapper->print_unix_dialog_set_has_selection(pDialog, TRUE);
-
- GtkPrintSettings* const pSettings(getSettings());
- m_pWrapper->print_settings_set_print_pages(pSettings, GTK_PRINT_PAGES_SELECTION);
- m_pWrapper->print_unix_dialog_set_settings(pDialog, pSettings);
- g_object_unref(G_OBJECT(pSettings));
+ case 0:
+ ePrintPages = GTK_PRINT_PAGES_ALL;
+ break;
+ case 1:
+ ePrintPages = GTK_PRINT_PAGES_RANGES;
+ break;
+ case 2:
+ if (m_pWrapper->supportsPrintSelection())
+ ePrintPages = GTK_PRINT_PAGES_SELECTION;
+ else
+ SAL_INFO("vcl.gtk", "the application wants to print a selection, but the present gtk version does not support it");
+ break;
+ default:
+ SAL_WARN("vcl.gtk", "unexpected selection type: " << nSelectionType);
}
+ m_pWrapper->print_settings_set_print_pages(pSettings, ePrintPages);
+ m_pWrapper->print_unix_dialog_set_settings(pDialog, pSettings);
+ g_object_unref(G_OBJECT(pSettings));
}
}