Kaydet (Commit) 9ec21486 authored tarafından Regina Henschel's avatar Regina Henschel

#i107734 Support for Math Input Panel in Windows 7

The patch introduces a new command .uno:ImportMathClipboard to module Math.
It imports MathML content from clipboard and transforms it to Starmath
It handles clipboard MIME type 'application/mathml+xml' and
plain text, which can be interpreted as MathML segment.
It partly solves issues #i14252, #i34781, and #i53509 too.
Review by: Hanya <hanya.runo@gmail.com>
üst 024b54d6
......@@ -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", "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
......
......@@ -77,6 +77,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:InsertCommand" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Insert Command</value>
......
......@@ -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
......@@ -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", "MathML", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
};
return &aInstance[0];
}
......
......@@ -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)
......
......@@ -423,6 +423,31 @@ 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
()
......
......@@ -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
[
......
......@@ -64,6 +64,7 @@
#include <vcl/menu.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/wrkwin.hxx>
#include <unotools/streamwrap.hxx>
#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<com::sun::star::io::XInputStream> 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)
......
......@@ -104,6 +104,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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment