summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dtrans/source/win32/ftransl/ftransl.cxx2
-rw-r--r--include/sot/formats.hxx3
-rw-r--r--officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu5
-rw-r--r--sot/source/base/exchange.cxx1
-rw-r--r--starmath/inc/starmath.hrc1
-rw-r--r--starmath/sdi/smath.sdi23
-rw-r--r--starmath/sdi/smslots.sdi6
-rw-r--r--starmath/source/view.cxx75
-rw-r--r--starmath/uiconfig/smath/menubar/menubar.xml1
9 files changed, 116 insertions, 1 deletions
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index bc14f54391bb..7fe0b55d98bd 100644
--- a/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/dtrans/source/win32/ftransl/ftransl.cxx
@@ -458,6 +458,8 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable()
m_TranslTable.push_back(FormatEntry("image/bmp", "Windows Bitmap", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SotClipboardFormatId::PNG
m_TranslTable.push_back(FormatEntry("image/png", "PNG", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
+ //SotClipboardFormatId::MATHML
+ m_TranslTable.push_back(FormatEntry("application/mathml+xml", "MathML", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SotClipboardFormatId::DUMMY3
m_TranslTable.push_back(FormatEntry("application/x-openoffice-dummy3;windows_formatname=\"SO_DUMMYFORMAT_3\"", "SO_DUMMYFORMAT_3", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SotClipboardFormatId::DUMMY4
diff --git a/include/sot/formats.hxx b/include/sot/formats.hxx
index cb2ee82ad74a..c85a10fb7c03 100644
--- a/include/sot/formats.hxx
+++ b/include/sot/formats.hxx
@@ -185,8 +185,9 @@ enum class SotClipboardFormatId : sal_uLong
HC_GDIMETAFILE = 140,
PNG = 141,
STARWRITERGLOB_8_TEMPLATE = 142,
+ MATHML = 143,
// the point at which we start allocating "runtime" format IDs
- USER_END = STARWRITERGLOB_8_TEMPLATE
+ USER_END = MATHML
};
/** Make it easier to iterate over format IDs */
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
index 02c5b52c99f3..4d612cd79156 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
@@ -43,6 +43,11 @@
<value xml:lang="en-US">~Import Formula...</value>
</prop>
</node>
+ <node oor:name=".uno:ImportMathMLClipboard" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Import MathML from Clipboard</value>
+ </prop>
+ </node>
<node oor:name=".uno:FitInWindow" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Fit To Window</value>
diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index 8b3541f09ad1..599525d2cc29 100644
--- a/sot/source/base/exchange.cxx
+++ b/sot/source/base/exchange.cxx
@@ -201,6 +201,7 @@ namespace
/*140 SotClipboardFormatId::GDIMETAFILE*/ { "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"", "High Contrast GDIMetaFile", &cppu::UnoType<Sequence<sal_Int8>>::get() },
/*141 SotClipboardFormatId::PNG*/ { "image/png", "PNG Bitmap", &cppu::UnoType<Sequence<sal_Int8>>::get() },
/*142 SotClipboardFormatId::STARWRITERGLOB_8_TEMPLATE*/ { MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_TEMPLATE_ASCII, "Writer/Global 8 Template", &cppu::UnoType<Sequence<sal_Int8>>::get() },
+ /*143 SotClipboardFormatId::MATHML*/ { "application/mathml+xml", "MathML", &::cppu::UnoType<const Sequence< sal_Int8 >>::get() },
};
return &aInstance[0];
}
diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc
index 7196b26dd269..6bf6e2124b9e 100644
--- a/starmath/inc/starmath.hrc
+++ b/starmath/inc/starmath.hrc
@@ -45,6 +45,7 @@
#define SID_SYMBOLS (SID_SMA_START + 56) // Has to be picked up again for now!
#define SID_TEXTMODE (SID_SMA_START + 57)
#define SID_IMPORT_FORMULA (SID_SMA_START + 58)
+#define SID_IMPORT_MATHML_CLIPBOARD (SID_SMA_START + 59)
#define SID_TEXT (SID_SMA_START + 100)
#define SID_GAPHIC_SM (SID_SMA_START + 101)
/** Command for inserting a symbol specified by a string (Inserts an SmSpecialNode) */
diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi
index 94caccacec4b..bbf5a6bedb6f 100644
--- a/starmath/sdi/smath.sdi
+++ b/starmath/sdi/smath.sdi
@@ -418,6 +418,29 @@ SfxBoolItem ImportFormula SID_IMPORT_FORMULA
GroupId = GID_INSERT;
]
+SfxBoolItem ImportMathMLClipboard SID_IMPORT_MATHML_CLIPBOARD
+()
+[
+ /* flags: */
+ AutoUpdate = FALSE,
+ Cachable = Cachable,
+ FastCall = TRUE,
+ HasCoreId = FALSE, /*obsolete */
+ HasDialog = FALSE, /*obsolete */
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE, /*obsolete */
+ RecordPerSet;
+ Synchron;
+
+ /* config: */
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ StatusBarConfig = FALSE,
+ ToolBoxConfig = TRUE,
+ GroupId = GID_INSERT;
+]
SfxVoidItem LoadSymbols SID_LOADSYMBOLS
()
diff --git a/starmath/sdi/smslots.sdi b/starmath/sdi/smslots.sdi
index 9857d3902bb6..a43eb7c38bff 100644
--- a/starmath/sdi/smslots.sdi
+++ b/starmath/sdi/smslots.sdi
@@ -251,6 +251,12 @@ interface FormulaView
StateMethod = GetState ;
Export = FALSE ;
]
+ SID_IMPORT_MATHML_CLIPBOARD //idlpp ole : no , status : no
+ [
+ ExecMethod = Execute ;
+ StateMethod = GetState ;
+ Export = FALSE ;
+ ]
//idlpp kein Menueeintrag , also keine Texte
SID_ATTR_ZOOM //idlpp ole : no , status : no
[
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 6bed0c31235b..1c4ca5401969 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -61,6 +61,7 @@
#include <vcl/settings.hxx>
#include <fstream>
+#include <unotools/streamwrap.hxx>
#include "unomodel.hxx"
#include "view.hxx"
@@ -1653,6 +1654,80 @@ void SmViewShell::Execute(SfxRequest& rReq)
break;
}
+ case SID_IMPORT_MATHML_CLIPBOARD:
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard(GetEditWindow()) );
+ uno::Reference < io::XInputStream > xStrm;
+ SotClipboardFormatId nId = SOT_FORMAT_SYSTEM_START; //dummy initialize to avoid warning
+ if ( aDataHelper.GetTransferable().is() )
+ {
+ if (aDataHelper.HasFormat(nId = SotClipboardFormatId::MATHML))
+ {
+ xStrm = aDataHelper.GetInputStream(nId, "");
+ if (xStrm.is())
+ {
+ SfxMedium* pClipboardMedium = new SfxMedium();
+ pClipboardMedium->GetItemSet(); //generate initial itemset, not sure if necessary
+ const SfxFilter* pMathFilter =
+ SfxFilter::GetFilterByName(OUString::createFromAscii(MATHML_XML));
+ pClipboardMedium->SetFilter(pMathFilter);
+ pClipboardMedium->setStreamToLoadFrom(xStrm, true /*bIsReadOnly*/);
+ InsertFrom(*pClipboardMedium);
+ GetDoc()->UpdateText();
+ delete pClipboardMedium;
+ }
+ }
+ else
+ {
+ if (aDataHelper.HasFormat(nId = SotClipboardFormatId::STRING))
+ {
+ // In case of FORMAT_STRING no stream exists, need to generate one
+ ::rtl::OUString aString;
+ if (aDataHelper.GetString( nId, aString))
+ {
+ SfxMedium* pClipboardMedium = new SfxMedium();
+ pClipboardMedium->GetItemSet(); //generates initial itemset, not sure if necessary
+ const SfxFilter* pMathFilter =
+ SfxFilter::GetFilterByName(OUString::createFromAscii(MATHML_XML));
+ pClipboardMedium->SetFilter(pMathFilter);
+
+ SvMemoryStream * pStrm;
+ // The text to be imported might asserts encoding like 'encoding="utf-8"' but FORMAT_STRING is UTF-16.
+ // Force encoding to UTF-16, if encoding exists.
+ bool bForceUTF16 = false;
+ sal_Int32 nPosL = aString.indexOf( OUString::createFromAscii("encoding=\""));
+ sal_Int32 nPosU = -1;
+ if ( nPosL >= 0 && nPosL +10 < aString.getLength() )
+ {
+ nPosL += 10;
+ nPosU = aString.indexOf( '"',nPosL);
+ if (nPosU > nPosL)
+ {
+ bForceUTF16 = true;
+ }
+ }
+ if ( bForceUTF16 )
+ {
+ OUString aNewString = aString.replaceAt( nPosL,nPosU-nPosL,OUString::createFromAscii("UTF-16"));
+ pStrm = new SvMemoryStream( (void*)aNewString.getStr(), aNewString.getLength() * sizeof(sal_Unicode), StreamMode::READ);
+ }
+ else
+ {
+ pStrm = new SvMemoryStream( (void*)aString.getStr(), aString.getLength() * sizeof(sal_Unicode), StreamMode::READ);
+ }
+ uno::Reference<io::XInputStream> xStrm2( new ::utl::OInputStreamWrapper(*pStrm) );
+ pClipboardMedium->setStreamToLoadFrom(xStrm2, true /*bIsReadOnly*/);
+ InsertFrom(*pClipboardMedium);
+ GetDoc()->UpdateText();
+ delete pClipboardMedium;
+ delete pStrm;
+ }
+ }
+ }
+ }
+ break;
+ }
+
case SID_NEXTERR:
NextError();
if (pWin)
diff --git a/starmath/uiconfig/smath/menubar/menubar.xml b/starmath/uiconfig/smath/menubar/menubar.xml
index 5a8edbb23763..60c48ff20b4c 100644
--- a/starmath/uiconfig/smath/menubar/menubar.xml
+++ b/starmath/uiconfig/smath/menubar/menubar.xml
@@ -116,6 +116,7 @@
<menu:menupopup>
<menu:menuitem menu:id=".uno:SymbolCatalogue"/>
<menu:menuitem menu:id=".uno:ImportFormula"/>
+ <menu:menuitem menu:id=".uno:ImportMathMLClipboard"/>
<menu:menuseparator/>
<menu:menu menu:id=".uno:MacrosMenu">
<menu:menupopup>