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:
> 
> (1)
> Has someone tried such already and found, that it is not possible?

i have no idea about clipboards or Math, but i'm armed with git grep :)

> (2)
> The comments in file exchange.cxx refer to a document "CLIP.SDW". Has 
> someone this document and can provide it?

ehhh.... i'd not hold my breath on that one :)

> (3)
> I have added a .uno command which is executed in 
> SmViewShell::Execute(SfxRequest& rReq)
> 
> My current attempt looks like this:
> 
> TransferableDataHelper aDataHelper( 
> TransferableDataHelper::CreateFromSystemClipboard(GetEditWindow()) );
> SotFormatStringId nId;
> DataFlavorExVector* pFormats;
> pFormats = &aDataHelper.GetDataFlavorExVector();
> DataFlavorExVector::iterator aIter( 
> ((DataFlavorExVector&)*pFormats).begin() ),
>                                  aEnd( 
> ((DataFlavorExVector&)*pFormats).end() );
> while ( aIter != aEnd )
> {
>      nId = (*aIter).mnSotId;
> ...
>      aIter++;
> }
> 
> I get some nId-values and for some of them I can get a stream and can 
> look at the content. But the clipboard content, which is generated by 
> the Windows program "Math Input Control" (mip.exe) is not noticed. But I 
> see that the clipboard has a content "MathML" and a content "MathML 
> Presentation" using the clipboard viewer "Free Clipboard Viewer 2.0". 
> Why do I get no nId for it?

include/sot/exchange.hxx:

struct DataFlavorEx : public ::com::sun::star::datatransfer::DataFlavor

this has a "SotClipboardFormatId mnSotId" and a "string MimeType" - how
does the system specifc clipboard data get translated to that...

> (4)
> The numbers I get in nId are those from the list in exchange.cxx, and 
> for "application/mathml+xml", which is not listed there, I get the next 
> one following the list. But how can I get the MimeType or the 
> HumanPresentableName for the detected nId? My following try does not 
> work, the strings are empty in all cases:
> 
> ::com::sun::star::datatransfer::DataFlavor aFlavor;
> SotExchange::GetFormatDataFlavor( nId, aFlavor ) )
> String sHumanPresentableName(aFlavor.HumanPresentableName);
> String sMimeType(aFlavor.MimeType);

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.

> (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.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to