[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-5-0' - 3 commits - filter/Library_pdffilter.mk filter/source filter/uiconfig include/vcl officecfg/registry sc/source vcl/source
Katarina Behrens
Katarina.Behrens at cib.de
Tue Sep 27 14:55:38 UTC 2016
filter/Library_pdffilter.mk | 1
filter/source/pdf/impdialog.cxx | 76 ++++++++++
filter/source/pdf/impdialog.hxx | 23 ++-
filter/uiconfig/ui/pdfgeneralpage.ui | 73 +++++++++-
include/vcl/pdfextoutdevdata.hxx | 1
include/vcl/pdfwriter.hxx | 1
officecfg/registry/schema/org/openoffice/Office/Common.xcs | 14 +
sc/source/ui/view/output2.cxx | 39 +++++
vcl/source/gdi/pdfextoutdevdata.cxx | 21 ++
vcl/source/gdi/pdfwriter.cxx | 5
vcl/source/gdi/pdfwriter_impl.cxx | 93 +++++++++++++
vcl/source/gdi/pdfwriter_impl.hxx | 4
12 files changed, 340 insertions(+), 11 deletions(-)
New commits:
commit 732a2ea84e7c9c04314f3b59596f0f457bf8bb9a
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed Apr 6 23:06:37 2016 +0200
PDF export of cell formulas now configurable in UI
Of course, only in Calc. I had to make filter/pdf depend
on svxcore (because of ColorListBox) but little harm done,
other filters in this dir depend on it already too
Change-Id: Id5bf99fdc738aea073bf5315e37ed5002ab0f926
diff --git a/filter/Library_pdffilter.mk b/filter/Library_pdffilter.mk
index 6de7d34..a3151ee 100644
--- a/filter/Library_pdffilter.mk
+++ b/filter/Library_pdffilter.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_use_custom_headers,pdffilter,\
$(eval $(call gb_Library_use_libraries,pdffilter,\
svt \
+ svxcore \
sfx \
tk \
vcl \
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 89a1351..b775805 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -25,7 +25,12 @@
#include <vcl/layout.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
+#include <sfx2/objsh.hxx>
#include "sfx2/passwd.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/svxids.hrc>
+#include <svx/xtable.hxx>
#include "svtools/miscopt.hxx"
#include "comphelper/storagehelper.hxx"
@@ -75,6 +80,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mnGeneralPageId(0),
mbIsPresentation( false ),
mbIsWriter( false ),
+ mbIsSpreadsheet( false ),
mbSelectionPresent( false ),
mbUseCTLFont( false ),
@@ -84,6 +90,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mnMaxImageResolution( 300 ),
mbUseTaggedPDF( false ),
mbExportNotes( true ),
+ mbExportFormulaAnnotation( false ),
mbViewPDF( false ),
mbExportNotesPages( false ),
mbUseTransitionEffects( false ),
@@ -95,6 +102,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mbExportBookmarks( true ),
mbExportHiddenSlides ( false),
mnOpenBookmarkLevels( -1 ),
+ mnAnnotColor( -1 ),
mbHideViewerToolbar( false ),
mbHideViewerMenubar( false ),
@@ -176,6 +184,8 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mbIsPresentation = true;
if ( xInfo->supportsService( "com.sun.star.text.GenericTextDocument" ) )
mbIsWriter = true;
+ if ( xInfo->supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ mbIsSpreadsheet = true;
}
}
catch(const RuntimeException &)
@@ -195,6 +205,8 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
if ( mbIsPresentation )
mbExportNotesPages = maConfigItem.ReadBool( "ExportNotesPages", false );
mbExportNotes = maConfigItem.ReadBool( "ExportNotes", false );
+ mbExportFormulaAnnotation = maConfigItem.ReadBool( "ExportFormulaAsAnnotation", false );
+ mnAnnotColor = maConfigItem.ReadInt32( "FormulaAnnotationHighlightColor", -1 );
mbViewPDF = maConfigItem.ReadBool( "ViewPDFAfterExport", false );
mbExportBookmarks = maConfigItem.ReadBool( "ExportBookmarks", true );
@@ -397,6 +409,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
if ( mbIsPresentation )
maConfigItem.WriteBool( "ExportNotesPages", mbExportNotesPages );
maConfigItem.WriteBool( "ExportNotes", mbExportNotes );
+ maConfigItem.WriteBool( "ExportFormulaAsAnnotation", mbExportFormulaAnnotation );
maConfigItem.WriteBool( "ViewPDFAfterExport", mbViewPDF );
maConfigItem.WriteBool( "ExportBookmarks", mbExportBookmarks );
@@ -428,6 +441,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
maConfigItem.WriteInt32( "PageLayout", mnPageLayout );
maConfigItem.WriteBool( "FirstPageOnLeft", mbFirstPageLeft );
maConfigItem.WriteInt32( "OpenBookmarkLevels", mnOpenBookmarkLevels );
+ maConfigItem.WriteInt32( "FormulaAnnotationHighlightColor", mnAnnotColor );
maConfigItem.WriteBool( "ExportLinksRelativeFsys", mbExportRelativeFsysLinks );
maConfigItem.WriteInt32("PDFViewSelection", mnViewPDFMode );
@@ -516,6 +530,7 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(vcl::Window* pParent, const SfxItemSe
, mbExportFormFieldsUserSelection(false)
, mbIsPresentation(false)
, mbIsWriter(false)
+ , mbIsSpreadsheet(false)
, mpaParent(0)
{
get(mpRbAll, "all");
@@ -543,12 +558,19 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(vcl::Window* pParent, const SfxItemSe
get(mpCbExportHiddenSlides, "hiddenpages");
get(mpCbExportNotes, "comments");
get(mpCbExportNotesPages, "notes");
+
+ get(mpFormulaFrame, "formulaframe");
+ get(mpCbExportFormulaAnnotations, "formulas");
+ get(mpFtAnnotColor, "annotation_label");
+ get(mpLbAnnotColor, "annotation_color");
+
get(mpCbExportEmptyPages, "emptypages");
get(mpCbViewPDF, "viewpdf");
get(mpCbWatermark, "watermark");
get(mpFtWatermark, "watermarklabel");
get(mpEdWatermark, "watermarkentry");
+ get(mpFtTransparent, "transparent");
}
@@ -580,11 +602,16 @@ void ImpPDFTabGeneralPage::dispose()
mpCbExportNotes.clear();
mpCbViewPDF.clear();
mpCbExportNotesPages.clear();
+ mpFormsFrame.clear();
+ mpCbExportFormulaAnnotations.clear();
+ mpFtAnnotColor.clear();
+ mpLbAnnotColor.clear();
mpCbExportEmptyPages.clear();
mpCbAddStream.clear();
mpCbWatermark.clear();
- mpFtWatermark.clear();
mpEdWatermark.clear();
+ mpFtWatermark.clear();
+ mpFtTransparent.clear();
mpaParent.clear();
SfxTabPage::dispose();
}
@@ -602,6 +629,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem( ImpPDFTabDialog* paParent )
mpRbSelection->Enable( paParent->mbSelectionPresent );
mbIsPresentation = paParent->mbIsPresentation;
mbIsWriter = paParent->mbIsWriter;
+ mbIsSpreadsheet = paParent->mbIsSpreadsheet;
mpCbExportEmptyPages->Enable( mbIsWriter );
@@ -672,6 +700,41 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem( ImpPDFTabDialog* paParent )
mpCbExportHiddenSlides->Check(false);
}
+ if ( mbIsSpreadsheet )
+ {
+ mpCbExportFormulaAnnotations->Show(true);
+ mpFtAnnotColor->Show(true);
+ mpLbAnnotColor->Show(true);
+
+ mpCbExportFormulaAnnotations->Check( paParent->mbExportFormulaAnnotation );
+ mpFormulaFrame->Enable( paParent->mbExportFormulaAnnotation );
+
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ XColorListRef pColorTable;
+
+ if ( pDocSh )
+ {
+ mpLbAnnotColor->InsertEntry( mpFtTransparent->GetText());
+
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ if ( pItem != nullptr )
+ pColorTable = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
+
+ if ( pColorTable.is() )
+ {
+ for ( long i = 0; i < pColorTable->Count(); i++ )
+ {
+ XColorEntry* pEntry = pColorTable->GetColor(i);
+ mpLbAnnotColor->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ }
+
+ mpLbAnnotColor->SelectEntry( Color( paParent->mnAnnotColor) );
+ }
+
+ mpCbExportFormulaAnnotations->SetToggleHdl( LINK( this, ImpPDFTabGeneralPage, ToggleExportFormulaAnnotations ) );
+ }
+
mpCbExportEmptyPages->Check(!paParent->mbIsSkipEmptyPages);
mpCbAddStream->Show(true);
@@ -697,6 +760,11 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* paParent )
paParent->mbExportBookmarks = mpCbExportBookmarks->IsChecked();
if ( mbIsPresentation )
paParent->mbExportHiddenSlides = mpCbExportHiddenSlides->IsChecked();
+ if ( mbIsSpreadsheet )
+ {
+ paParent->mbExportFormulaAnnotation = mpCbExportFormulaAnnotations->IsChecked();
+ paParent->mnAnnotColor = mpLbAnnotColor->GetSelectEntryColor().GetColor();
+ }
paParent->mbIsSkipEmptyPages = !mpCbExportEmptyPages->IsChecked();
paParent->mbAddStream = mpCbAddStream->IsVisible() && mpCbAddStream->IsChecked();
@@ -853,6 +921,12 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportPDFAHdl)
return 0;
}
+IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleExportFormulaAnnotations)
+{
+ mpFormulaFrame->Enable(mpCbExportFormulaAnnotations->IsChecked());
+ return 0;
+}
+
// the option features tab page
ImpPDFTabOpnFtrPage::ImpPDFTabOpnFtrPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
: SfxTabPage(pParent, "PdfViewPage","filter/ui/pdfviewpage.ui", &rCoreSet)
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index e828721..59b2969 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -34,6 +34,7 @@
#include "vcl/pdfwriter.hxx"
#include <vcl/FilterConfigItem.hxx>
+#include <svtools/ctrlbox.hxx>
#include "sfx2/tabdlg.hxx"
@@ -93,26 +94,29 @@ protected:
//the following data are the configuration used throughout the dialog and pages
bool mbIsPresentation;
bool mbIsWriter;
+ bool mbIsSpreadsheet;
bool mbSelectionPresent;
bool mbUseCTLFont;
bool mbUseLosslessCompression;
- sal_Int32 mnQuality;
+ sal_Int32 mnQuality;
bool mbReduceImageResolution;
- sal_Int32 mnMaxImageResolution;
+ sal_Int32 mnMaxImageResolution;
bool mbUseTaggedPDF;
- sal_Int32 mnPDFTypeSelection;
+ sal_Int32 mnPDFTypeSelection;
bool mbExportNotes;
+ bool mbExportFormulaAnnotation;
bool mbViewPDF;
bool mbExportNotesPages;
bool mbUseTransitionEffects;
bool mbIsSkipEmptyPages;
bool mbAddStream;
- sal_Int32 mnFormsType;
+ sal_Int32 mnFormsType;
bool mbExportFormFields;
bool mbAllowDuplicateFieldNames;
bool mbExportBookmarks;
bool mbExportHiddenSlides;
- sal_Int32 mnOpenBookmarkLevels;
+ sal_Int32 mnOpenBookmarkLevels;
+ sal_Int32 mnAnnotColor;
bool mbHideViewerToolbar;
bool mbHideViewerMenubar;
@@ -216,6 +220,12 @@ class ImpPDFTabGeneralPage : public SfxTabPage
VclPtr<CheckBox> mpCbExportBookmarks;
VclPtr<CheckBox> mpCbExportHiddenSlides;
VclPtr<CheckBox> mpCbExportNotes;
+
+ VclPtr<VclContainer> mpFormulaFrame;
+ VclPtr<CheckBox> mpCbExportFormulaAnnotations;
+ VclPtr<FixedText> mpFtAnnotColor;
+ VclPtr<ColorListBox> mpLbAnnotColor;
+
VclPtr<CheckBox> mpCbViewPDF;
VclPtr<CheckBox> mpCbExportNotesPages;
@@ -224,10 +234,12 @@ class ImpPDFTabGeneralPage : public SfxTabPage
VclPtr<CheckBox> mpCbWatermark;
VclPtr<FixedText> mpFtWatermark;
+ VclPtr<FixedText> mpFtTransparent;
VclPtr<Edit> mpEdWatermark;
bool mbIsPresentation;
bool mbIsWriter;
+ bool mbIsSpreadsheet;
VclPtr<ImpPDFTabDialog> mpaParent;
@@ -237,6 +249,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
DECL_LINK( ToggleWatermarkHdl, void* );
DECL_LINK( ToggleAddStreamHdl, void* );
DECL_LINK( ToggleExportFormFieldsHdl, void* );
+ DECL_LINK( ToggleExportFormulaAnnotations, void* );
public:
DECL_LINK( ToggleExportPDFAHdl, void* );
diff --git a/filter/uiconfig/ui/pdfgeneralpage.ui b/filter/uiconfig/ui/pdfgeneralpage.ui
index 7ba4a25..567a64b 100644
--- a/filter/uiconfig/ui/pdfgeneralpage.ui
+++ b/filter/uiconfig/ui/pdfgeneralpage.ui
@@ -2,6 +2,7 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.0"/>
+ <requires lib="LibreOffice" version="1.0"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">100</property>
@@ -604,7 +605,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">9</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -619,7 +620,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">12</property>
</packing>
</child>
<child>
@@ -652,6 +653,74 @@
<property name="top_attach">7</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="formulas">
+ <property name="label" translatable="yes">Export cell formulas as annotations</property>
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.49000000953674316</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">9</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="formulaframe">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="annotation_label">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Highlight color: </property>
+ <property name="ellipsize">end</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="svtlo-ColorListBox" id="annotation_color">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">10</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="transparent">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Transparent</property>
+ <property name="ellipsize">middle</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">13</property>
+ </packing>
+ </child>
</object>
</child>
</object>
commit 3e56f61f3f08fc3451efdbe66894274a4c5c43ce
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Mar 22 13:59:01 2016 +0100
Make PDF export of cell formulas depend on configuration
Change-Id: I5ff3ea5e9f512dc0901f37af04d191d1d6ae4984
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index e779d35..0dafeb9 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5176,6 +5176,20 @@
</constraints>
<value>0</value>
</prop>
+ <prop oor:name="ExportFormulaAsAnnotation" oor:type="xs:boolean" oor:nillable="false">
+ <info>
+ <desc>Specifies if cell formulas are exported to PDF as highlight annotations
+ (in Calc documents only).</desc>
+ </info>
+ <value>false</value>
+ </prop>
+ <prop oor:name="FormulaAnnotationHighlightColor" oor:type="xs:int" oor:nillable="false">
+ <info>
+ <desc>Specifies colour used to highlight cells that have formula in exported PDF,
+ -1 if no highlight should be used (Calc documents only).</desc>
+ </info>
+ <value>-1</value>
+ </prop>
<prop oor:name="AllowDuplicateFieldNames" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Specifies whether multiple form fields exported are allowed
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 5ebd84c..2ba870a 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -44,6 +44,7 @@
#include <vcl/outdev.hxx>
#include <vcl/pdfextoutdevdata.hxx>
#include <vcl/settings.hxx>
+#include <officecfg/Office/Common.hxx>
#include "output.hxx"
#include "document.hxx"
@@ -1466,6 +1467,7 @@ Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScA
"LayoutStrings: unterschiedliche MapUnits ?!?!" );
vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, mpDev->GetExtOutDevData() );
+ bool bExportFormulaAnnotation = officecfg::Office::Common::Filter::PDF::Export::ExportFormulaAsAnnotation::get();
sc::IdleSwitch aIdleSwitch(*mpDoc, false);
ScDrawStringsVars aVars( this, bPixelToLogic );
@@ -2136,7 +2138,7 @@ Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScA
Rectangle aURLRect( aURLStart, aVars.GetTextSize() );
if (bHasURL)
lcl_DoHyperlinkResult(mpDev, aURLRect, aCell);
- else
+ else if (bExportFormulaAnnotation)
lcl_DoFormulaAnnotation(mpDev, aURLRect, aCell);
}
}
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 80878be..3f7982c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -39,6 +39,7 @@
#include <cppuhelper/implbase1.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <o3tl/numeric.hxx>
+#include <officecfg/Office/Common.hxx>
#include <osl/file.hxx>
#include <osl/thread.h>
#include <rtl/crc.h>
@@ -4711,6 +4712,8 @@ bool PDFWriterImpl::emitNoteAnnotations()
bool PDFWriterImpl::emitFormulaAnnotations()
{
int nFormulaNotes = m_aFormulaNotes.size();
+ sal_Int32 nColor = officecfg::Office::Common::Filter::PDF::Export::FormulaAnnotationHighlightColor::get();
+ Color aColor( nColor );
for (int i = 0; i < nFormulaNotes; i++)
{
@@ -4754,7 +4757,16 @@ bool PDFWriterImpl::emitFormulaAnnotations()
aLine.append( "]" );
aLine.append( "/F 4" );
- aLine.append( "/C [1 1 0]");
+
+ if ( nColor == -1 )
+ aLine.append( "/C [0.63 0.63 0.63]/CA 0") ; // light grey-ish pop-up note, transparent highlight
+ else
+ {
+ aLine.append( "/C [");
+ appendColor( aColor, aLine);
+ aLine.append( "]/CA 1");
+ }
+
aLine.append( "/Border [0 0 1]");
aLine.append( "/Contents\n" );
appendLiteralStringEncrypt( rFormulaNote.m_aContents.Contents, rFormulaNote.m_nObject, aLine );
commit 761eeb30408e7a06089ec753d4507a5d05065369
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Tue Mar 8 11:41:26 2016 +0100
Show cell formula as annotation in exported PDF
Change-Id: Idca8f6a27453a0f41566098a1720ee345eff3af6
diff --git a/include/vcl/pdfextoutdevdata.hxx b/include/vcl/pdfextoutdevdata.hxx
index 85541fe..3af6fd9 100644
--- a/include/vcl/pdfextoutdevdata.hxx
+++ b/include/vcl/pdfextoutdevdata.hxx
@@ -318,6 +318,7 @@ public :
or -1 in which case the current page is used
*/
void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
+ void CreateFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
/** begin a new logical structure element
diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index 0567957..f31b934 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -1084,6 +1084,7 @@ The following structure describes the permissions used in PDF security
or -1 in which case the current page is used
*/
void CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
+ void CreateFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
/** begin a new logical structure element
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 7368322..5ebd84c 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -847,6 +847,33 @@ static void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, S
}
}
+static void lcl_DoFormulaAnnotation( OutputDevice* pDev, const Rectangle& rRect, ScRefCellValue& rCell )
+{
+ vcl::PDFExtOutDevData* pPDFData = dynamic_cast< vcl::PDFExtOutDevData* >( pDev->GetExtOutDevData() );
+
+ ScFormulaCell* pFCell = rCell.mpFormula;
+
+ if (pFCell && pPDFData)
+ {
+ OUString aFormula;
+ pFCell->GetFormula( aFormula );
+
+ if ( !aFormula.isEmpty() )
+ {
+ const OUString aEquals("=");
+ OUString aAnnotation;
+ vcl::PDFNote aPDFNote;
+
+ // chop off leading '=', some PDF viewers don't like it
+ if ( aFormula.startsWith( aEquals ) )
+ aAnnotation = aFormula.copy( 1, aFormula.getLength() - 1 );
+
+ aPDFNote.Contents = aAnnotation;
+ pPDFData->CreateFormulaAnnotation( rRect, aPDFNote);
+ }
+ }
+}
+
void ScOutputData::SetSyntaxColor( vcl::Font* pFont, const ScRefCellValue& rCell )
{
switch (rCell.meType)
@@ -2102,11 +2129,15 @@ Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScA
}
// PDF: whole-cell hyperlink from formula?
- bool bHasURL = pPDFData && aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->IsHyperLinkCell();
- if (bPaint && bHasURL)
+ bool bHasFormula = pPDFData && aCell.meType == CELLTYPE_FORMULA;
+ bool bHasURL = bHasFormula && aCell.mpFormula->IsHyperLinkCell();
+ if (bPaint && bHasFormula)
{
Rectangle aURLRect( aURLStart, aVars.GetTextSize() );
- lcl_DoHyperlinkResult(mpDev, aURLRect, aCell);
+ if (bHasURL)
+ lcl_DoHyperlinkResult(mpDev, aURLRect, aCell);
+ else
+ lcl_DoFormulaAnnotation(mpDev, aURLRect, aCell);
}
}
}
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index 3cab7d1..d8352037 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -36,6 +36,7 @@ struct PDFExtOutDevDataSync
enum Action{ CreateNamedDest,
CreateDest,
CreateLink,
+ CreateFormulaAnnotation,
SetLinkDest,
SetLinkURL,
RegisterDest,
@@ -83,6 +84,7 @@ struct GlobalSyncData
std::deque< OUString > mParaOUStrings;
std::deque< PDFWriter::DestAreaType > mParaDestAreaTypes;
std::deque< PDFNote > mParaPDFNotes;
+ std::deque< PDFNote > mParaFormulaNotes;
std::deque< PDFWriter::PageTransition > mParaPageTransitions;
::std::map< sal_Int32, PDFLinkDestination > mFutureDestinations;
@@ -251,6 +253,16 @@ void GlobalSyncData::PlayGlobalActions( PDFWriter& rWriter )
mParaPDFNotes.pop_front();
mParaInts.pop_front();
}
+ case PDFExtOutDevDataSync::CreateFormulaAnnotation :
+ {
+ rWriter.Push( PushFlags::MAPMODE );
+ rWriter.SetMapMode( mParaMapModes.front() );
+ rWriter.CreateFormulaAnnotation( mParaRects.front(), mParaFormulaNotes.front(), mParaInts.front() );
+ mParaMapModes.pop_front();
+ mParaRects.pop_front();
+ mParaFormulaNotes.pop_front();
+ mParaInts.pop_front();
+ }
break;
case PDFExtOutDevDataSync::SetAutoAdvanceTime :
{
@@ -477,6 +489,7 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, sal_uInt32& rCurGDIMtfAc
case PDFExtOutDevDataSync::SetOutlineItemText:
case PDFExtOutDevDataSync::SetOutlineItemDest:
case PDFExtOutDevDataSync::CreateNote:
+ case PDFExtOutDevDataSync::CreateFormulaAnnotation:
case PDFExtOutDevDataSync::SetAutoAdvanceTime:
case PDFExtOutDevDataSync::SetPageTransition:
break;
@@ -663,6 +676,14 @@ void PDFExtOutDevData::CreateNote( const Rectangle& rRect, const PDFNote& rNote,
mpGlobalSyncData->mParaPDFNotes.push_back( rNote );
mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
}
+void PDFExtOutDevData::CreateFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
+{
+ mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::CreateFormulaAnnotation );
+ mpGlobalSyncData->mParaRects.push_back( rRect );
+ mpGlobalSyncData->mParaMapModes.push_back( mrOutDev.GetMapMode() );
+ mpGlobalSyncData->mParaFormulaNotes.push_back( rNote );
+ mpGlobalSyncData->mParaInts.push_back( nPageNr == -1 ? mnPage : nPageNr );
+}
void PDFExtOutDevData::SetPageTransition( PDFWriter::PageTransition eType, sal_uInt32 nMilliSec, sal_Int32 nPageNr )
{
mpGlobalSyncData->mActions.push_back( PDFExtOutDevDataSync::SetPageTransition );
diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx
index 85fae2d..4af6cde 100644
--- a/vcl/source/gdi/pdfwriter.cxx
+++ b/vcl/source/gdi/pdfwriter.cxx
@@ -387,6 +387,11 @@ void PDFWriter::CreateNote( const Rectangle& rRect, const PDFNote& rNote, sal_In
xImplementation->createNote( rRect, rNote, nPageNr );
}
+void PDFWriter::CreateFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
+{
+ xImplementation->createFormulaAnnotation( rRect, rNote, nPageNr );
+}
+
sal_Int32 PDFWriter::BeginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias )
{
return xImplementation->beginStructureElement( eType, rAlias );
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 44d1f45..80878be 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4708,6 +4708,65 @@ bool PDFWriterImpl::emitNoteAnnotations()
return true;
}
+bool PDFWriterImpl::emitFormulaAnnotations()
+{
+ int nFormulaNotes = m_aFormulaNotes.size();
+
+ for (int i = 0; i < nFormulaNotes; i++)
+ {
+ const PDFNoteEntry &rFormulaNote = m_aFormulaNotes[i];
+
+ OStringBuffer aLine( 1024 );
+ aLine.append( rFormulaNote.m_nObject );
+ aLine.append( " 0 obj\n" );
+
+ aLine.append( "<</Type/Annot" );
+ aLine.append( "/Rect[" );
+
+ appendFixedInt( rFormulaNote.m_aRect.Left(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Top(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Right(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Bottom(), aLine );
+ aLine.append( "]" );
+
+ aLine.append( "/Subtype/Highlight" );
+ aLine.append( "/QuadPoints[" );
+
+ appendFixedInt( rFormulaNote.m_aRect.Left(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Top(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Right(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Top(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Left(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Bottom(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Right(), aLine );
+ aLine.append( ' ' );
+ appendFixedInt( rFormulaNote.m_aRect.Bottom(), aLine );
+ aLine.append( ' ' );
+ aLine.append( "]" );
+
+ aLine.append( "/F 4" );
+ aLine.append( "/C [1 1 0]");
+ aLine.append( "/Border [0 0 1]");
+ aLine.append( "/Contents\n" );
+ appendLiteralStringEncrypt( rFormulaNote.m_aContents.Contents, rFormulaNote.m_nObject, aLine );
+ aLine.append( "\n" );
+
+ aLine.append( ">>\nendobj\n\n" );
+ CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) );
+ }
+
+ return true;
+}
+
Font PDFWriterImpl::replaceFont( const vcl::Font& rControlFont, const vcl::Font& rAppSetFont )
{
bool bAdjustSize = false;
@@ -5621,6 +5680,7 @@ bool PDFWriterImpl::emitAnnotations()
CHECK_RETURN( emitLinkAnnotations() );
CHECK_RETURN( emitNoteAnnotations() );
+ CHECK_RETURN( emitFormulaAnnotations() );
CHECK_RETURN( emitWidgetAnnotations() );
return true;
@@ -12198,6 +12258,27 @@ void PDFWriterImpl::createNote( const Rectangle& rRect, const PDFNote& rNote, sa
m_aPages[ nPageNr ].m_aAnnotations.push_back( m_aNotes.back().m_nObject );
}
+void PDFWriterImpl::createFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr )
+{
+ if( nPageNr < 0 )
+ nPageNr = m_nCurrentPage;
+
+ if( nPageNr < 0 || nPageNr >= (sal_Int32)m_aPages.size() )
+ return;
+
+ m_aFormulaNotes.push_back( PDFNoteEntry() );
+ m_aFormulaNotes.back().m_nObject = createObject();
+ m_aFormulaNotes.back().m_aContents = rNote;
+ m_aFormulaNotes.back().m_aRect = rRect;
+ // convert to default user space now, since the mapmode may change
+ m_aPages[nPageNr].convertRect( m_aFormulaNotes.back().m_aRect );
+
+ // insert note to page's annotation list
+ m_aPages[ nPageNr ].m_aAnnotations.push_back( m_aFormulaNotes.back().m_nObject );
+
+ return;
+}
+
sal_Int32 PDFWriterImpl::createLink( const Rectangle& rRect, sal_Int32 nPageNr )
{
if( nPageNr < 0 )
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index cf38905..b3ae494 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -630,6 +630,7 @@ private:
/* contains all notes set during PDF creation
*/
std::vector<PDFNoteEntry> m_aNotes;
+ std::vector<PDFNoteEntry> m_aFormulaNotes;
/* the root of the structure tree
*/
std::vector<PDFStructureElement> m_aStructure;
@@ -921,6 +922,8 @@ i12626
bool emitLinkAnnotations();
// write all notes
bool emitNoteAnnotations();
+ // write cell formulas as annotations
+ bool emitFormulaAnnotations();
// write the appearance streams of a widget
bool emitAppearances( PDFWidget& rWidget, OStringBuffer& rAnnotDict );
// clean up radio button "On" values
@@ -1267,6 +1270,7 @@ public:
// notes
void createNote( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
+ void createFormulaAnnotation( const Rectangle& rRect, const PDFNote& rNote, sal_Int32 nPageNr = -1 );
// structure elements
sal_Int32 beginStructureElement( PDFWriter::StructElement eType, const OUString& rAlias );
void endStructureElement();
More information about the Libreoffice-commits
mailing list