[Libreoffice-commits] core.git: 2 commits - dtrans/source include/sal include/sot officecfg/registry sot/source starmath/inc starmath/sdi starmath/source starmath/uiconfig vcl/unx
Regina Henschel
regina at apache.org
Wed Jul 8 08:04:57 PDT 2015
dtrans/source/win32/ftransl/ftransl.cxx | 2
include/sal/log-areas.dox | 1
include/sot/formats.hxx | 3
officecfg/registry/data/org/openoffice/Office/UI/MathCommands.xcu | 5
sot/source/base/exchange.cxx | 1
starmath/inc/starmath.hrc | 1
starmath/sdi/smath.sdi | 23 +++
starmath/sdi/smslots.sdi | 6
starmath/source/view.cxx | 75 ++++++++++
starmath/uiconfig/smath/menubar/menubar.xml | 1
vcl/unx/generic/dtrans/X11_selection.cxx | 6
11 files changed, 119 insertions(+), 5 deletions(-)
New commits:
commit 64bc8b45b5c23efc5fe57585a69aa4263aaf4e83
Author: Regina Henschel <regina at apache.org>
Date: Wed Jul 8 12:31:43 2015 +0000
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 at gmail.com>
(cherry picked from commit 9ec2148653436be8612273439180749e71e2ce58)
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
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index bc14f54..7fe0b55 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 cb2ee82..c85a10f 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 02c5b52..4d612cd 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 8b3541f..599525d 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 7196b26..6bf6e21 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 94cacca..bbf5a6b 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 9857d39..a43eb7c 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 6bed0c3..1c4ca54 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 5a8edbb..60c48ff 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>
commit 26aebe26f706d9fbc9c113f5c1fdc495578435bf
Author: Michael Stahl <mstahl at redhat.com>
Date: Wed Jul 8 15:47:57 2015 +0200
vcl: use SAL_INFO for available X11 clipboard formats
Change-Id: Ifbd87e59fa91241dd5852f7dc6b63e65d8ca6bad
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 70f3456..3eb754c 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -407,6 +407,7 @@ certain functionality.
@li @c vcl.sm - Session Manager
@li @c vcl.unity
@li @c vcl.unx.print
+ at li @c vcl.unx.dtrans
@li @c vcl.virdev
@li @c vcl.window
@li @c vcl.wmf
diff --git a/vcl/unx/generic/dtrans/X11_selection.cxx b/vcl/unx/generic/dtrans/X11_selection.cxx
index fc4e97b..a323791 100644
--- a/vcl/unx/generic/dtrans/X11_selection.cxx
+++ b/vcl/unx/generic/dtrans/X11_selection.cxx
@@ -1305,10 +1305,8 @@ bool SelectionManager::getPasteDataTypes( Atom selection, Sequence< DataFlavor >
sal_Int32 nNativeTypesIndex = 0;
while( nAtoms-- )
{
-#if OSL_DEBUG_LEVEL > 1
- if( *pAtoms && *pAtoms < 0x01000000 )
- fprintf( stderr, "native type: %s\n", OUStringToOString( getString( *pAtoms ), RTL_TEXTENCODING_ISO_8859_1 ).getStr() );
-#endif
+ SAL_INFO_IF(*pAtoms && *pAtoms < 0x01000000, "vcl.unx.dtrans",
+ "getPasteDataTypes: available: \"" << getString(*pAtoms) << "\"");
if( *pAtoms == m_nCOMPOUNDAtom )
bHaveText = bHaveCompound = true;
else if( *pAtoms && *pAtoms < 0x01000000 )
More information about the Libreoffice-commits
mailing list