Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


Hi Michael,

thank-you for looking at my problems.

Michael Stahl schrieb:
On 05.06.2015 01:44, Regina Henschel wrote:
Hi all,

I struggle with the clipboard. My goal is to import MathML in module
Math from clipboard, similar as it is imported from file. But I'm stuck.
Therefore some questions:
[skipped a lot of text]

include/sot/formats.hxx: enum class SotClipboardFormatId

there is no MathML in there, but various STARMATH_* ones.

     // the point at which we start allocating "runtime" format IDs
     USER_END  = STARWRITERGLOB_8_TEMPLATE

so what you probably have as ID is "user-defined", which means we can't
do anything with it really.

it looks like there needs to be some mapping from the OS-specific
clipboard to these office-internal IDs - if there's no ID for MathML it
can't be mapped.

there is a big array in sot/source/base/exchange.cxx, you probably need
to add an entry for MathML there.

the array is ordered and indexed by the SotClipboardFormatId.

/* 48 SotClipboardFormatId::STARMATH_50*/            {
"application/x-openoffice-starmath-50;windows_formatname=\"StarMath
5.0\"", "StarMath 5.0", &cppu::UnoType<Sequence<sal_Int8>>::get() },

that's the mime-type and human-readable name.

i was wondering how this would work on Windows, given that the Win32
clipboard presumably does not use mime-types; apparently the
";windows_formatname=\"...\"" appendix to the mime-type here covers that.

Helpful comments. Looking around I think, the connection to the OS is done in /main/dtrans/source/win32/

I have found the table m_TranslTable, which refers the SOT_FORMATSTR_IDs from exchange.cxx. I'll try what happens, when I add the MathML format there too. I had already added it in exchange.cxx, but that was not enough to be recognized. [I need some time for that. I will report back, when I have finished.]



(5)
I try to use SmViewShell::InsertFrom(SfxMedium &rMedium). It seems to
work, but when the process arrives at SmXMLImport::endDocument(void),
the node tree is empty.  Any tips, what I might have missed?

how do you prepare the SfxMedium?  i'm not sure if it requires an actual
file, or if it can read from an input stream (XInputStream); it probably
can't read from a Sequence<sal_Int8> buffer directly...

there is a SfxMedium::setStreamToLoadFrom() which looks promising.

I have used:

TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard(GetEditWindow()) );
uno::Reference < io::XInputStream > xStrm;
aDataHelper.GetInputStream( nId, xStrm );
SfxMedium* pClipboardMedium = new SfxMedium();
SfxMedium aClipboardMedium = *pClipboardMedium;
aClipboardMedium.setStreamToLoadFrom( xStrm, sal_True /*bIsReadOnly*/ );
InsertFrom(aClipboardMedium);


When I then proof it with

SvStream* pStream = aClipboardMedium.GetInStream();
...
sal_uLong nBytesRead = pStream->Read( aBuffer, nBufferSize );
printf("%s \n", aBuffer);

I can see, that the stream contains the expected MathML-source in case the clipboard viewer lists the clipboard format "application/mathml+xml".

In addition I have set the filter by

const SfxFilter* pMathFilter = SfxFilter::GetFilterByName( String::CreateFromAscii(MATHML_XML) );
aClipboardMedium.SetFilter(pMathFilter);

so that

if ( rFltName.EqualsAscii(MATHML_XML) )

in InsertFrom becomes true


I'm still a novice in coding and it might be, that I do basic things wrong.



you can create an input stream from the buffer via SvMemoryStream and
then wrap that in utl::OInputStreamWrapper.

You mean, it will be possible to use the "Unicode-Text"? That would help, when copying from Websites. But first I need to solve the problem, that I get no node-tree, and the problem to detect the clipboard correctly.

Kind regards
Regina

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.