summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-11-24 15:19:17 +0100
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-11-28 11:24:57 +0100
commit19e3bab1a8def52d9a60f67bd87697e828e37773 (patch)
tree80269931c3edab0ff0df07c5cc22c7c6052fa494 /filter
parent7765b442e13048f857fd7ee49ced1731caee297e (diff)
tdf#77650 Add option to place comments in margin (PDF Export)
This was somehow possible already when the document was printed with comments in margin before - but it was not possible to set this option when exporting a PDF via dialog or API. To use this setting via API, set the "ExportNotesInMargin" property. Change-Id: I97a80c5b3b3b2cde669496fd881a41ea0acc5c28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143234 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'filter')
-rw-r--r--filter/qa/data/commentsInMargin.odtbin0 -> 9938 bytes
-rw-r--r--filter/qa/pdf.cxx39
-rw-r--r--filter/source/pdf/impdialog.cxx12
-rw-r--r--filter/source/pdf/impdialog.hxx2
-rw-r--r--filter/source/pdf/pdfexport.cxx7
-rw-r--r--filter/source/pdf/pdfexport.hxx1
-rw-r--r--filter/source/pdf/pdffilter.cxx1
-rw-r--r--filter/uiconfig/ui/pdfgeneralpage.ui36
8 files changed, 89 insertions, 9 deletions
diff --git a/filter/qa/data/commentsInMargin.odt b/filter/qa/data/commentsInMargin.odt
new file mode 100644
index 000000000000..3286f9e01899
--- /dev/null
+++ b/filter/qa/data/commentsInMargin.odt
Binary files differ
diff --git a/filter/qa/pdf.cxx b/filter/qa/pdf.cxx
index b631a3f8a4a8..cc83f59e1652 100644
--- a/filter/qa/pdf.cxx
+++ b/filter/qa/pdf.cxx
@@ -37,6 +37,7 @@ public:
void setUp() override;
void tearDown() override;
+ void doTestCommentsInMargin(bool commentsInMarginEnabled);
};
void Test::setUp()
@@ -144,6 +145,44 @@ CPPUNIT_TEST_FIXTURE(Test, testPdfDecompositionSize)
#endif
}
+void Test::doTestCommentsInMargin(bool commentsInMarginEnabled)
+{
+ std::shared_ptr<vcl::pdf::PDFium> pPDFium = vcl::pdf::PDFiumLibrary::get();
+ if (!pPDFium)
+ return;
+
+ loadFromURL(u"commentsInMargin.odt");
+ uno::Reference<css::lang::XMultiServiceFactory> xFactory = getMultiServiceFactory();
+ uno::Reference<document::XFilter> xFilter(
+ xFactory->createInstance("com.sun.star.document.PDFFilter"), uno::UNO_QUERY);
+ uno::Reference<document::XExporter> xExporter(xFilter, uno::UNO_QUERY);
+ xExporter->setSourceDocument(mxComponent);
+ SvMemoryStream aStream;
+ uno::Reference<io::XOutputStream> xOutputStream(new utl::OStreamWrapper(aStream));
+ uno::Sequence<beans::PropertyValue> aFilterData{ comphelper::makePropertyValue(
+ "ExportNotesInMargin", commentsInMarginEnabled) };
+ uno::Sequence<beans::PropertyValue> aDescriptor{
+ comphelper::makePropertyValue("FilterName", OUString("writer_pdf_Export")),
+ comphelper::makePropertyValue("FilterData", aFilterData),
+ comphelper::makePropertyValue("OutputStream", xOutputStream),
+ };
+ xFilter->filter(aDescriptor);
+
+ // Make sure the number of objects is correct
+ std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+ = pPDFium->openDocument(aStream.GetData(), aStream.GetSize(), OString());
+ CPPUNIT_ASSERT(pPdfDocument);
+ CPPUNIT_ASSERT_EQUAL(commentsInMarginEnabled ? 9 : 1,
+ pPdfDocument->openPage(0)->getObjectCount());
+}
+
+CPPUNIT_TEST_FIXTURE(Test, testCommentsInMargin)
+{
+ // Test that setting/unsetting the "ExportNotesInMargin" property works correctly
+ doTestCommentsInMargin(true);
+ doTestCommentsInMargin(false);
+}
+
CPPUNIT_TEST_FIXTURE(Test, testWatermarkColor)
{
// Given an empty Writer document:
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 16b4b8a00616..fd68322f1a23 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -67,6 +67,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const Sequence< Property
mbUseTaggedPDF( false ),
mbUseTaggedPDFUserSelection( false ),
mbExportNotes( true ),
+ mbExportNotesInMargin( false ),
mbViewPDF( false ),
mbUseReferenceXObject( false ),
mbExportNotesPages( false ),
@@ -191,6 +192,8 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const Sequence< Property
mbExportOnlyNotesPages = maConfigItem.ReadBool( "ExportOnlyNotesPages", false );
}
mbExportNotes = maConfigItem.ReadBool( "ExportNotes", false );
+ if (mbIsWriter)
+ mbExportNotesInMargin = maConfigItem.ReadBool( "ExportNotesInMargin", false );
mbViewPDF = maConfigItem.ReadBool( "ViewPDFAfterExport", false );
mbExportBookmarks = maConfigItem.ReadBool( "ExportBookmarks", true );
@@ -417,6 +420,8 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
maConfigItem.WriteBool( "ExportOnlyNotesPages", mbExportOnlyNotesPages );
}
maConfigItem.WriteBool( "ExportNotes", mbExportNotes );
+ if (mbIsWriter)
+ maConfigItem.WriteBool( "ExportNotesInMargin", mbExportNotesInMargin );
maConfigItem.WriteBool( "ViewPDFAfterExport", mbViewPDF );
maConfigItem.WriteBool( "ExportBookmarks", mbExportBookmarks );
@@ -518,6 +523,7 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogC
, mxCbExportHiddenSlides(m_xBuilder->weld_check_button("hiddenpages"))
, mxCbSinglePageSheets(m_xBuilder->weld_check_button("singlepagesheets"))
, mxCbExportNotes(m_xBuilder->weld_check_button("comments"))
+ , mxCbExportNotesInMargin(m_xBuilder->weld_check_button("commentsinmargin"))
, mxCbViewPDF(m_xBuilder->weld_check_button("viewpdf"))
, mxCbUseReferenceXObject(m_xBuilder->weld_check_button("usereferencexobject"))
, mxCbExportNotesPages(m_xBuilder->weld_check_button("notes"))
@@ -556,6 +562,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
mbIsWriter = pParent->mbIsWriter;
mbIsSpreadsheet = pParent->mbIsSpreadsheet;
+ mxCbExportNotesInMargin->set_sensitive( mbIsWriter );
mxCbExportEmptyPages->set_sensitive( mbIsWriter );
mxCbExportPlaceholders->set_sensitive( mbIsWriter );
@@ -618,6 +625,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
mxCbExportBookmarks->set_active( pParent->mbExportBookmarks );
mxCbExportNotes->set_active( pParent->mbExportNotes );
+ mxCbExportNotesInMargin->set_active( pParent->mbExportNotesInMargin );
mxCbViewPDF->set_active( pParent->mbViewPDF);
if ( mbIsPresentation )
@@ -663,10 +671,12 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
{
// tdf#54908 Make selection active if there is a selection in Writer's version
mxRbSelection->set_active( bSelectionPresent );
+ mxCbExportNotesInMargin->set_active(pParent->mbExportNotesInMargin);
}
else
{
mxCbExportPlaceholders->set_active(false);
+ mxCbExportNotesInMargin->set_active(false);
}
mxCbExportEmptyPages->set_active(!pParent->mbIsSkipEmptyPages);
mxCbExportPlaceholders->set_active(pParent->mbIsExportPlaceholders);
@@ -686,6 +696,8 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent )
pParent->mbReduceImageResolution = mxCbReduceImageResolution->get_active();
pParent->mnMaxImageResolution = mxCoReduceImageResolution->get_active_text().toInt32();
pParent->mbExportNotes = mxCbExportNotes->get_active();
+ if (mbIsWriter)
+ pParent->mbExportNotesInMargin = mxCbExportNotesInMargin->get_active();
pParent->mbViewPDF = mxCbViewPDF->get_active();
pParent->mbUseReferenceXObject = mxCbUseReferenceXObject->get_active();
if ( mbIsPresentation )
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index 9dc97d653e37..828422bdc63e 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -83,6 +83,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController
sal_Int32 mnPDFTypeSelection;
bool mbPDFUACompliance;
bool mbExportNotes;
+ bool mbExportNotesInMargin;
bool mbViewPDF;
bool mbUseReferenceXObject;
bool mbExportNotesPages;
@@ -202,6 +203,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
std::unique_ptr<weld::CheckButton> mxCbExportHiddenSlides;
std::unique_ptr<weld::CheckButton> mxCbSinglePageSheets;
std::unique_ptr<weld::CheckButton> mxCbExportNotes;
+ std::unique_ptr<weld::CheckButton> mxCbExportNotesInMargin;
std::unique_ptr<weld::CheckButton> mxCbViewPDF;
std::unique_ptr<weld::CheckButton> mxCbUseReferenceXObject;
std::unique_ptr<weld::CheckButton> mxCbExportNotesPages;
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 8204d6da86b3..338463f184f8 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -86,6 +86,7 @@ PDFExport::PDFExport( const Reference< XComponent >& rxSrcDoc,
mnPDFTypeSelection ( 0 ),
mbPDFUACompliance ( false),
mbExportNotes ( true ),
+ mbExportNotesInMargin ( false ),
mbExportPlaceholders ( false ),
mbUseReferenceXObject ( false ),
mbExportNotesPages ( false ),
@@ -518,6 +519,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
rProp.Value >>= mbPDFUACompliance;
else if ( rProp.Name == "ExportNotes" )
rProp.Value >>= mbExportNotes;
+ else if ( rProp.Name == "ExportNotesInMargin" )
+ rProp.Value >>= mbExportNotesInMargin;
else if ( rProp.Name == "ExportNotesPages" )
rProp.Value >>= mbExportNotesPages;
else if ( rProp.Name == "ExportOnlyNotesPages" )
@@ -935,6 +938,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
vcl::PDFExtOutDevData aPDFExtOutDevData( *pOut );
pOut->SetExtOutDevData( &aPDFExtOutDevData );
aPDFExtOutDevData.SetIsExportNotes( mbExportNotes );
+ aPDFExtOutDevData.SetIsExportNotesInMargin( mbExportNotesInMargin );
aPDFExtOutDevData.SetIsExportTaggedPDF( mbUseTaggedPDF );
aPDFExtOutDevData.SetIsExportTransitionEffects( mbUseTransitionEffects );
aPDFExtOutDevData.SetIsExportFormFields( mbExportFormFields );
@@ -954,7 +958,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
comphelper::makePropertyValue("IsSkipEmptyPages", mbSkipEmptyPages),
comphelper::makePropertyValue("PageRange", aPageRange),
comphelper::makePropertyValue("ExportPlaceholders", mbExportPlaceholders),
- comphelper::makePropertyValue("SinglePageSheets", mbSinglePageSheets)
+ comphelper::makePropertyValue("SinglePageSheets", mbSinglePageSheets),
+ comphelper::makePropertyValue("ExportNotesInMargin", mbExportNotesInMargin)
};
Any& rExportNotesValue = aRenderOptions.getArray()[ 1 ].Value;
diff --git a/filter/source/pdf/pdfexport.hxx b/filter/source/pdf/pdfexport.hxx
index dfd371c3177b..5dbe15e36846 100644
--- a/filter/source/pdf/pdfexport.hxx
+++ b/filter/source/pdf/pdfexport.hxx
@@ -48,6 +48,7 @@ private:
sal_Int32 mnPDFTypeSelection;
bool mbPDFUACompliance;
bool mbExportNotes;
+ bool mbExportNotesInMargin;
bool mbExportPlaceholders;
bool mbUseReferenceXObject;
bool mbExportNotesPages;
diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx
index f6596a3479e3..d28803aa01c9 100644
--- a/filter/source/pdf/pdffilter.cxx
+++ b/filter/source/pdf/pdffilter.cxx
@@ -110,6 +110,7 @@ bool PDFFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
aCfgItem.ReadInt32( "SelectPdfVersion", 0 );
aCfgItem.ReadBool("PDFUACompliance", false);
aCfgItem.ReadBool( "ExportNotes", false );
+ aCfgItem.ReadBool( "ExportNotesInMargin", false );
aCfgItem.ReadBool( "ExportPlaceholders", false );
aCfgItem.ReadBool( "ExportNotesPages", false );
aCfgItem.ReadBool( "ExportOnlyNotesPages", false );
diff --git a/filter/uiconfig/ui/pdfgeneralpage.ui b/filter/uiconfig/ui/pdfgeneralpage.ui
index 844e3c341a7c..f39034a9b184 100644
--- a/filter/uiconfig/ui/pdfgeneralpage.ui
+++ b/filter/uiconfig/ui/pdfgeneralpage.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 -->
+<!-- Generated with glade 3.40.0 -->
<interface domain="flt">
<requires lib="gtk+" version="3.20"/>
<object class="GtkSizeGroup"/>
@@ -790,7 +790,7 @@
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
- <!-- n-columns=1 n-rows=9 -->
+ <!-- n-columns=1 n-rows=10 -->
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -874,7 +874,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">7</property>
+ <property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -894,7 +894,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">8</property>
+ <property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -914,7 +914,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">5</property>
+ <property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -934,7 +934,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -955,7 +955,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">4</property>
+ <property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -975,7 +975,27 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">6</property>
+ <property name="top-attach">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="commentsinmargin">
+ <property name="label" translatable="yes" context="pdfgeneralpage|commentsinmargin">_Comments in margin</property>
+ <property name="visible">True</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">False</property>
+ <property name="halign">start</property>
+ <property name="use-underline">True</property>
+ <property name="draw-indicator">True</property>
+ <child internal-child="accessible">
+ <object class="AtkObject" id="commentsinmargin-atkobject">
+ <property name="AtkObject::accessible-description" translatable="yes" context="pdfgeneralpage|extended_tip|commentsinmargin">Select to export comments of Writer documents in the page margin.</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">3</property>
</packing>
</child>
</object>