diff --git a/main/dtrans/source/win32/ftransl/ftransl.cxx b/main/dtrans/source/win32/ftransl/ftransl.cxx
index 6706bc0..f4c2fba 100644
--- a/main/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/main/dtrans/source/win32/ftransl/ftransl.cxx
@@ -516,6 +516,8 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable()
m_TranslTable.push_back(FormatEntry("image/bmp", "Windows Bitmap", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SOT_FORMATSTR_ID_PNG
m_TranslTable.push_back(FormatEntry("image/png", "PNG", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
+ //SOT_FORMATSTR_ID_MATHML
+ m_TranslTable.push_back(FormatEntry("application/mathml+xml;windows_formatname=\"MathML\"", "MathML", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SOT_FORMATSTR_ID_DUMMY3
m_TranslTable.push_back(FormatEntry("application/x-openoffice-dummy3;windows_formatname=\"SO_DUMMYFORMAT_3\"", "SO_DUMMYFORMAT_3", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
//SOT_FORMATSTR_ID_DUMMY4
diff --git a/main/helpcontent2/source/text/smath/00/00000004.xhp b/main/helpcontent2/source/text/smath/00/00000004.xhp
index 70bf858..b0facf4 100644
--- a/main/helpcontent2/source/text/smath/00/00000004.xhp
+++ b/main/helpcontent2/source/text/smath/00/00000004.xhp
@@ -323,6 +323,8 @@
Choose Tools - Import Formula
+Choose Tools - Import MathML from Clipboard
+Choose Tools - Customize
diff --git a/main/helpcontent2/source/text/smath/01/06020000.xhp b/main/helpcontent2/source/text/smath/01/06020000.xhp
index dcc7b4d..e023fbe 100644
--- a/main/helpcontent2/source/text/smath/01/06020000.xhp
+++ b/main/helpcontent2/source/text/smath/01/06020000.xhp
@@ -2,7 +2,7 @@
@@ -30,14 +30,23 @@
-
-
-
- importing; %PRODUCTNAME Math formulasImport formula
+
+ importing; %PRODUCTNAME Math formulasMathML; import from fileImport Formula from FileThis command opens a dialog for importing a formula.The Insert dialog is set up like the Open dialog under File. Use the Insert dialog to load, edit and display a formula saved as a file in the Commands window.
+ You can import MathML files created by other applications as well. The MathML source must have a math element with an xmlns attribute with value "http://www.w3.org/1998/Math/MathML". The languages MathML and StarMath are not fully compatible, therefore you should revise the import result. For details about the language MathML see its specification.
+
+
+
+ MathML; import via clipboardimporting; MathMLImport MathML from Clipboard
+ This command transforms MathML clipboard content to StarMath and inserts it at the current cursor position.
+ If the transformation fails, nothing is inserted.
+
+
+
+ This command handles only MathML content. If you have copied a %PRODUCTNAME Math formula to clipboard, insert it using the command Paste under Edit.
-
+
Tools
-Use this menu to open and edit the symbol catalog, or import an external formula as a data file. The program interface can be adjusted to meet your requirements. You can also change the program options.
+Use this menu to open and edit the symbol catalog, or import an external formula as a data file or via clipboard. The program interface can be adjusted to meet your requirements. You can also change the program options.
-Import Formula
+Import Formula
+Import MathML from Clipboard
+
Customize
diff --git a/main/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu b/main/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
index c266fbf..babc106 100644
--- a/main/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
+++ b/main/officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
@@ -77,6 +77,11 @@
~Import Formula...
+
+
+ Import MathML from Clipboard
+
+ Insert Command
diff --git a/main/sot/inc/sot/formats.hxx b/main/sot/inc/sot/formats.hxx
index 2a4e828..07c8ce8 100644
--- a/main/sot/inc/sot/formats.hxx
+++ b/main/sot/inc/sot/formats.hxx
@@ -182,7 +182,8 @@
#define SOT_FORMATSTR_ID_STARBASE_8 ((sal_uLong)139)
#define SOT_FORMATSTR_ID_HC_GDIMETAFILE ((sal_uLong)140)
#define SOT_FORMATSTR_ID_PNG ((sal_uLong)141)
-#define SOT_FORMATSTR_ID_USER_END SOT_FORMATSTR_ID_PNG
+#define SOT_FORMATSTR_ID_MATHML ((sal_uLong)142)
+#define SOT_FORMATSTR_ID_USER_END SOT_FORMATSTR_ID_MATHML
#endif // _SOT_FORMATS_HXX
diff --git a/main/sot/source/base/exchange.cxx b/main/sot/source/base/exchange.cxx
index f0becad..c91dc4f 100644
--- a/main/sot/source/base/exchange.cxx
+++ b/main/sot/source/base/exchange.cxx
@@ -208,6 +208,7 @@ namespace
/*139 SOT_FORMATSTR_ID_STARBASE_8*/ { MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII, "StarBase 8", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
/*140 SOT_FORMAT_GDIMETAFILE*/ { "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"", "High Contrast GDIMetaFile", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
/*141 SOT_FORMATSTR_ID_PNG*/ { "image/png", "PNG Bitmap", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
+ /*142 SOT_FORMATSTR_ID_MATHML*/ { "application/mathml+xml;windows_formatname=\"MathML\"", "MathML", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
};
return &aInstance[0];
}
diff --git a/main/starmath/inc/starmath.hrc b/main/starmath/inc/starmath.hrc
index e7de3d1..0f0674e 100644
--- a/main/starmath/inc/starmath.hrc
+++ b/main/starmath/inc/starmath.hrc
@@ -52,6 +52,7 @@
#define SID_SYMBOLS (SID_SMA_START + 56) // Muss erstmal wieder aufgenommen werden !
#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)
#define SID_FITINWINDOW (SID_SMA_START + 103)
diff --git a/main/starmath/sdi/smath.sdi b/main/starmath/sdi/smath.sdi
index 6d1086d..aebc51d 100644
--- a/main/starmath/sdi/smath.sdi
+++ b/main/starmath/sdi/smath.sdi
@@ -424,6 +424,31 @@ SfxBoolItem ImportFormula SID_IMPORT_FORMULA
]
//--------------------------------------------------------------------------
+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/main/starmath/sdi/smslots.sdi b/main/starmath/sdi/smslots.sdi
index 9712703..c4c7da2 100644
--- a/main/starmath/sdi/smslots.sdi
+++ b/main/starmath/sdi/smslots.sdi
@@ -277,6 +277,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/main/starmath/source/view.cxx b/main/starmath/source/view.cxx
index 70ee7ce..7b4e8cb 100644
--- a/main/starmath/source/view.cxx
+++ b/main/starmath/source/view.cxx
@@ -64,6 +64,7 @@
#include
#include
#include
+#include
#include "unomodel.hxx"
#include "view.hxx"
@@ -90,6 +91,8 @@ using namespace com::sun::star;
using namespace com::sun::star::accessibility;
using namespace com::sun::star::uno;
+using ::rtl::OUString;
+
//////////////////////////////////////////////////////////////////////
SmGraphicWindow::SmGraphicWindow(SmViewShell* pShell):
@@ -1601,6 +1604,77 @@ void SmViewShell::Execute(SfxRequest& rReq)
break;
}
+ case SID_IMPORT_MATHML_CLIPBOARD:
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard(GetEditWindow()) );
+ uno::Reference < io::XInputStream > xStrm;
+ SotFormatStringId nId = SOT_FORMAT_SYSTEM_START; //dummy initialize to avoid warning
+ if ( aDataHelper.GetTransferable().is() )
+ {
+ if ( aDataHelper.HasFormat( nId = SOT_FORMATSTR_ID_MATHML ) )
+ {
+ if ( aDataHelper.GetInputStream( nId, xStrm ) && xStrm.is() )
+ {
+ SfxMedium* pClipboardMedium = new SfxMedium();
+ pClipboardMedium->GetItemSet(); //generate initial itemset, not sure if necessary
+ const SfxFilter* pMathFilter = SfxFilter::GetFilterByName( String::CreateFromAscii(MATHML_XML) );
+ pClipboardMedium->SetFilter(pMathFilter);
+ pClipboardMedium->setStreamToLoadFrom( xStrm, sal_True /*bIsReadOnly*/ );
+ InsertFrom(*pClipboardMedium);
+ GetDoc()->UpdateText();
+ delete pClipboardMedium;
+ }
+ }
+ else
+ {
+ if ( aDataHelper.HasFormat( nId = FORMAT_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( String::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), STREAM_READ);
+ }
+ else
+ {
+ pStrm = new SvMemoryStream( (void*)aString.getStr(), aString.getLength() * sizeof(sal_Unicode), STREAM_READ);
+ }
+ com::sun::star::uno::Reference xStrm( new ::utl::OInputStreamWrapper( *pStrm ) );
+ pClipboardMedium->setStreamToLoadFrom( xStrm, sal_True /*bIsReadOnly*/ );
+ InsertFrom(*pClipboardMedium);
+ GetDoc()->UpdateText();
+ delete pClipboardMedium;
+ delete pStrm;
+ }
+ }
+ }
+ }
+ break;
+ }
+
case SID_NEXTERR:
NextError();
if (pWin)
diff --git a/main/starmath/uiconfig/smath/menubar/menubar.xml b/main/starmath/uiconfig/smath/menubar/menubar.xml
index 08af6fd..d1ac4c8 100644
--- a/main/starmath/uiconfig/smath/menubar/menubar.xml
+++ b/main/starmath/uiconfig/smath/menubar/menubar.xml
@@ -104,6 +104,7 @@
+