Kaydet (Commit) 64bc8b45 authored tarafından Regina Henschel's avatar Regina Henschel Kaydeden (comit) Michael Stahl

i#107734 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>
(cherry picked from commit 9ec21486)

Conflicts:
	dtrans/source/win32/ftransl/ftransl.cxx
	officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu
	sot/inc/sot/formats.hxx
	sot/source/base/exchange.cxx
	starmath/sdi/smath.sdi
	starmath/source/view.cxx

Change-Id: I6cb5e8f737ee2e39f9ce96aba841db347a8806e4
üst 26aebe26
......@@ -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
......
......@@ -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 */
......
......@@ -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>
......
......@@ -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];
}
......
......@@ -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) */
......
......@@ -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
()
......
......@@ -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
[
......
......@@ -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)
......
......@@ -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>
......
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