[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-5-1' - 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 15:06:59 UTC 2016
Rebased ref, commits from common ancestor:
commit 260d341f17f052d6a44fc1f68b3d5c198b1dbd49
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
Conflicts:
filter/source/pdf/impdialog.cxx
filter/uiconfig/ui/pdfgeneralpage.ui
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 f1c86a8..9a4a622 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"
@@ -73,6 +78,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mnGeneralPageId(0),
mbIsPresentation( false ),
mbIsWriter( false ),
+ mbIsSpreadsheet( false ),
mbSelectionPresent( false ),
mbUseCTLFont( false ),
@@ -82,6 +88,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mnMaxImageResolution( 300 ),
mbUseTaggedPDF( false ),
mbExportNotes( true ),
+ mbExportFormulaAnnotation( false ),
mbViewPDF( false ),
mbExportNotesPages( false ),
mbUseTransitionEffects( false ),
@@ -94,6 +101,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(vcl::Window* pParent, Sequence< PropertyValue >
mbExportBookmarks( true ),
mbExportHiddenSlides ( false),
mnOpenBookmarkLevels( -1 ),
+ mnAnnotColor( -1 ),
mbHideViewerToolbar( false ),
mbHideViewerMenubar( false ),
@@ -175,6 +183,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 &)
@@ -194,6 +204,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 );
@@ -396,6 +408,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,8 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(vcl::Window* pParent, const SfxItemSe
, mbExportFormFieldsUserSelection(false)
, mbIsPresentation(false)
, mbIsWriter(false)
+ , mbIsSpreadsheet(false)
+
, mpaParent(nullptr)
{
get(mpRbAll, "all");
@@ -543,6 +559,12 @@ 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(mpCbExportPlaceholders, "exportplaceholders" );
get(mpCbViewPDF, "viewpdf");
@@ -550,6 +572,7 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(vcl::Window* pParent, const SfxItemSe
get(mpCbWatermark, "watermark");
get(mpFtWatermark, "watermarklabel");
get(mpEdWatermark, "watermarkentry");
+ get(mpFtTransparent, "transparent");
}
@@ -581,12 +604,17 @@ void ImpPDFTabGeneralPage::dispose()
mpCbExportNotes.clear();
mpCbViewPDF.clear();
mpCbExportNotesPages.clear();
+ mpFormsFrame.clear();
+ mpCbExportFormulaAnnotations.clear();
+ mpFtAnnotColor.clear();
+ mpLbAnnotColor.clear();
mpCbExportEmptyPages.clear();
mpCbExportPlaceholders.clear();
mpCbAddStream.clear();
mpCbWatermark.clear();
- mpFtWatermark.clear();
mpEdWatermark.clear();
+ mpFtWatermark.clear();
+ mpFtTransparent.clear();
mpaParent.clear();
SfxTabPage::dispose();
}
@@ -604,6 +632,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem( ImpPDFTabDialog* paParent )
mpRbSelection->Enable( paParent->mbSelectionPresent );
mbIsPresentation = paParent->mbIsPresentation;
mbIsWriter = paParent->mbIsWriter;
+ mbIsSpreadsheet = paParent->mbIsSpreadsheet;
mpCbExportEmptyPages->Enable( mbIsWriter );
mpCbExportPlaceholders->Enable( mbIsWriter );
@@ -674,6 +703,41 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem( ImpPDFTabDialog* paParent )
mpCbExportHiddenSlides->Show(false);
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( COL_TRANSPARENT, 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 ) );
+ }
+
mpCbExportPlaceholders->Show(mbIsWriter);
if( !mbIsWriter )
{
@@ -705,6 +769,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->mbIsExportPlaceholders = mpCbExportPlaceholders->IsChecked();
@@ -886,6 +955,10 @@ ImpPDFTabOpnFtrPage::ImpPDFTabOpnFtrPage(vcl::Window* pParent, const SfxItemSet&
mpRbMagnZoom->SetToggleHdl( LINK( this, ImpPDFTabOpnFtrPage, ToggleRbMagnHdl ) );
}
+IMPL_LINK_NOARG_TYPED(ImpPDFTabGeneralPage, ToggleExportFormulaAnnotations, CheckBox&, void)
+{
+ mpFormulaFrame->Enable(mpCbExportFormulaAnnotations->IsChecked());
+}
ImpPDFTabOpnFtrPage::~ImpPDFTabOpnFtrPage()
{
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index 72938b0..8d931a5 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,6 +94,7 @@ 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;
@@ -102,6 +104,7 @@ protected:
bool mbUseTaggedPDF;
sal_Int32 mnPDFTypeSelection;
bool mbExportNotes;
+ bool mbExportFormulaAnnotation;
bool mbViewPDF;
bool mbExportNotesPages;
bool mbUseTransitionEffects;
@@ -114,6 +117,7 @@ protected:
bool mbExportBookmarks;
bool mbExportHiddenSlides;
sal_Int32 mnOpenBookmarkLevels;
+ sal_Int32 mnAnnotColor;
bool mbHideViewerToolbar;
bool mbHideViewerMenubar;
@@ -217,6 +221,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;
@@ -226,10 +236,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;
@@ -239,6 +251,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
DECL_LINK_TYPED( ToggleWatermarkHdl, CheckBox&, void );
DECL_LINK_TYPED( ToggleAddStreamHdl, CheckBox&, void );
DECL_LINK_TYPED( ToggleExportFormFieldsHdl, CheckBox&, void );
+ DECL_LINK_TYPED( ToggleExportFormulaAnnotations, CheckBox&, void );
void TogglePagesHdl();
public:
diff --git a/filter/uiconfig/ui/pdfgeneralpage.ui b/filter/uiconfig/ui/pdfgeneralpage.ui
index 8a46e0f..cc0da7f 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>
@@ -619,7 +620,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">10</property>
+ <property name="top_attach">11</property>
</packing>
</child>
<child>
@@ -634,7 +635,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">11</property>
+ <property name="top_attach">12</property>
</packing>
</child>
<child>
@@ -667,6 +668,74 @@
<property name="top_attach">8</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 fb6abf18a5de28b7124fbe18c6388b99ad4367a9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Fri Mar 11 17:58:47 2016 +0100
Make PDF export of cell formulas depend on configuration
Change-Id: I0d1828cb93290313f578cf40b7cd021dedd6b5ed
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index f6e85b5..49b4764 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5183,6 +5183,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 38c0b5f..c1b4036 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -45,6 +45,7 @@
#include <vcl/pdfextoutdevdata.hxx>
#include <vcl/settings.hxx>
#include <o3tl/make_unique.hxx>
+#include <officecfg/Office/Common.hxx>
#include "output.hxx"
#include "document.hxx"
@@ -1468,6 +1469,7 @@ Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, const ScA
"LayoutStrings: different MapUnits ?!?!" );
vcl::PDFExtOutDevData* pPDFData = dynamic_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 5edc960..22865ec 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -39,6 +39,7 @@
#include <cppuhelper/implbase.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>
@@ -4712,6 +4713,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++)
{
@@ -4755,7 +4758,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 a700e51bd8ada5fda4367cf9d2ca5af9fde4fcdd
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 1140180..2553d9f 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 c10f1cc..225966b 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -1086,6 +1086,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 718b3cc..38c0b5f 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -851,6 +851,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 75ce7de..f7fb254 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 :
{
@@ -489,6 +501,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;
@@ -679,6 +692,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 6a22e4a..fb9092d 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 6051b9c..5edc960 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4709,6 +4709,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;
@@ -5622,6 +5681,7 @@ bool PDFWriterImpl::emitAnnotations()
CHECK_RETURN( emitLinkAnnotations() );
CHECK_RETURN( emitNoteAnnotations() );
+ CHECK_RETURN( emitFormulaAnnotations() );
CHECK_RETURN( emitWidgetAnnotations() );
return true;
@@ -12187,6 +12247,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 306bb15..71af7df 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -621,6 +621,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;
@@ -875,6 +876,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
@@ -1219,6 +1222,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